1.下載軟件Selenium Driver
官方下載地址: ? https://www.selenium.dev/downloads/
解壓selenium-java-3.141.59.zip文件到java項目 seleniumDemo,并降解壓的文件放入依賴中
(1)雙擊項目的src打開項目結構,或右鍵-打開模塊設置,選擇模塊-依賴:
3)選擇項目下的已解壓selenium-java-3.141.59后的lib目錄及兩個jar,點擊確定完成即可。
2.下載IE驅動
IE驅動下載地址:https://www.selenium.dev/downloads/,根據(jù)自己電腦選擇對應的下載,放入電腦E:\driver
3.配置path路徑
在配置path中新增一個,E:\driver
4.寫selenium代碼
package testSelenium;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class Test {
public static void main(String[] args) {
// 指定IE driver的存放路徑
System.setProperty("webdriver.ie.driver", "E:\\driver\\IEDriverServer.exe");
//實例化webdriver對象,啟動IE瀏覽器
WebDriver driver = new InternetExplorerDriver();
driver.get("https://goobe.io/search.aspx?k=vue");
}
}
5.設置IE瀏覽器
1)打開edge瀏覽器,啟用IE模式,找到更多工具的 Internet選項
2)點擊安全,將下圖四個選項都設置成 啟用保護模式
6.設置注冊表
1)win+r打開注冊表
根據(jù)https://www.selenium.dev/documentation/ie_driver_server/#required-configuration里面進行配置文章來源:http://www.zghlxwxcb.cn/news/detail-612968.html
7.運行代碼
文章來源地址http://www.zghlxwxcb.cn/news/detail-612968.html
到了這里,關于selenium的java方式打開IE瀏覽器的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!