您好,登錄后才能下訂單哦!
1.selenium中啟動ie瀏覽器代時碼(紅框中)如下 :
點擊運行時,控制臺報錯如下:
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的設置,不要在任何情況下使用保護模式(protected mode),另一種即是在前面代碼中如下片段在運行時設置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.關于下拉框的定位法 :
方法一:如果該下拉框是html原生的select ,則可用selenium的select方法定位; 但是如果是自己開發的下拉框,則不能用該方法。
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("中級");
否則將會報如下錯誤:
3.關于編輯器中文本框的定位問題,在<frame>里,但找不到任何可定位的元素,待解決。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。