今天研究了下ie、Chrome、Firefox瀏覽器執行腳本
1.首先firefox下執行時,我是安裝在d盤了,所以要更改路徑
//如果火狐瀏覽器沒有默認安裝在C盤,需要制定其路徑
System.set WebDriver driver = new FirefoxDriver();
2.在chrome下執行時,遇到了如下問題
Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://code.google.com/p/chromedriver/downloads/list
解決方法:
下載chrome驅動插件,(包含ie驅動插件),代碼如下,還有問題的話,把路徑加到path變量中
http://yunpan.cn/c3kPMJTZDDLyv 訪問密碼 4dd5
1 //谷歌瀏覽器2 System.setProperty("webdriver.chrome.driver", "C://Users//Administrator//Desktop//testzidong//selenium//anzhuangbao//chromedriver_win32//chromedriver.exe"); 3 WebDriver driver=new ChromeDriver();4
3.在ie下運行時出現上面類型問題。解決方法同上
代碼如下:
1 System.setProperty("webdriver.ie.driver", "C://Users//Administrator//Desktop//testzidong//selenium//anzhuangbao//IEDriverServer_x64_2.48.0//IEDriverServer.exe"); 2 WebDriver driver = new InternetExplorerDriver();
但是在運行時又包了其他錯。
解決方法如下: 把ie選項中的安全區域全部打上鉤
新聞熱點
疑難解答