简体   繁体   English

使用IntelliJ IDEA IDE进行Selenium自动化处理IE9时遇到错误

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

My code is : 我的代码是:

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());
    }
}

Getting an error as: 得到一个错误为:

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

I don't know what's wrong. 我不知道怎么了

The warning says what should you do: 警告提示您应该怎么做:

WARNING: This method of starting the IE driver is deprecated and will be removed in selenium 2.26. 警告:不建议使用这种启动IE驱动程序的方法,并将在硒2.26中将其删除。 Please download the IEDriverServer.exe from http://code.google.com/p/selenium/downloads/list and ensure that it is in your PATH. 请从http://code.google.com/p/selenium/downloads/list下载IEDriverServer.exe,并确保它位于您的PATH中。

So, first, download the IEDriverServer.exe from http://code.google.com/p/selenium/downloads/list 因此,首先,从http://code.google.com/p/selenium/downloads/list下载IEDriverServer.exe。

Correct way to start IE driver is: 启动IE驱动程序的正确方法是:

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

You are using an old version of Selenium and IEDriver. 您正在使用旧版本的Selenium和IEDriver。

Download the latest version of Selenium and the IEDriverServer from here: 从此处下载最新版本的Selenium IEDriverServer:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM