簡體   English   中英

使用IntelliJ IDEA IDE進行Selenium自動化處理IE9時遇到錯誤

[英]getting an error when opeming IE9 using IntelliJ IDEA IDE for Selenium automation

我的代碼是:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class Example
{
    public static void main(String[] a)
    {
        WebDriver driver = new InternetExplorerDriver() ;
        System.setProperty("sun.net.spi.nameservice.provider.1", "dns,sun");
        driver.navigate();
        driver.get("http://www.google.com/");
        System.out.println("Page title is: " + driver.getTitle());
    }
}

得到一個錯誤為:

WARNING: This method of starting the IE driver is deprecated and will be removed in selenium 2.26. Please download the IEDriverServer.exe from http://code.google.com/p/selenium/downloads/list and ensure that it is in your PATH.
Exception in thread "main" org.openqa.selenium.WebDriverException: 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: 289 milliseconds
Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:09:54'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_13'
Driver info: driver.version: InternetExplorerDriver
Session ID: 0521cc95-3fbb-43c8-9073-7602d937450b
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:498)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:182)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:167)
    at org.openqa.selenium.ie.InternetExplorerDriver.startSession(InternetExplorerDriver.java:133)
    at org.openqa.selenium.ie.InternetExplorerDriver.setup(InternetExplorerDriver.java:106)
    at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:52)
    at Example.main(Example.java:22)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Process finished with exit code 1

我不知道怎么了

警告提示您應該怎么做:

警告:不建議使用這種啟動IE驅動程序的方法,並將在硒2.26中將其刪除。 請從http://code.google.com/p/selenium/downloads/list下載IEDriverServer.exe,並確保它位於您的PATH中。

因此,首先,從http://code.google.com/p/selenium/downloads/list下載IEDriverServer.exe。

啟動IE驅動程序的正確方法是:

System.setProperty("webdriver.ie.driver", "path/to/ IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver() ;

您正在使用舊版本的Selenium和IEDriver。

從此處下載最新版本的Selenium IEDriverServer:

https://code.google.com/p/selenium/downloads/list

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM