您好,登錄后才能下訂單哦!
1.selenium中啟動ie瀏覽器代時碼(紅框中)如下 :
點(diǎn)擊運(yùn)行時,控制臺報(bào)錯如下:
Started InternetExplorerDriver server (64-bit)
2.53.0.0
Listening on port 31574
Only local connections are allowed
Exception in thread "main" org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 692 milliseconds
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40'
System info: host: 'XL-20150414QGDQ', ip: '192.168.80.6', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_80'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:234)
at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:182)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:174)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:146)
at Project1Class.main(Project1Class.java:13)
解決方法:
解決方法有兩種,一種是修改掉IE的設(shè)置,不要在任何情況下使用保護(hù)模式(protected mode),另一種即是在前面代碼中如下片段在運(yùn)行時設(shè)置IE的Capabilities。
添加后代碼如下:
DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
WebDriver driver = new InternetExplorerDriver(ieCapabilities);
提示錯誤信息可參考如下地址:https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver.
The latest version can be downloaded from http://selenium-release.storage.googleapis.com/index.html
2.關(guān)于下拉框的定位法 :
方法一:如果該下拉框是html原生的select ,則可用selenium的select方法定位; 但是如果是自己開發(fā)的下拉框,則不能用該方法。
Select selectCategory1 = new Select(driver.findElement(By.id("category_1")));
selectCategory1.selectByVisibleText("java");
Select selectCategory2 = new Select(driver.findElement(By.id("category_2")));
selectCategory2.selectByVisibleText("3D游戲");
Select selectCategory3 = new Select(driver.findElement(By.id("difficulty")));
selectCategory3.selectByVisibleText("中級");
否則將會報(bào)如下錯誤:
3.關(guān)于編輯器中文本框的定位問題,在<frame>里,但找不到任何可定位的元素,待解決。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。