简体   繁体   中英

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. Please download the IEDriverServer.exe from http://code.google.com/p/selenium/downloads/list and ensure that it is in your PATH.

So, first, download the IEDriverServer.exe from http://code.google.com/p/selenium/downloads/list

Correct way to start IE driver is:

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

You are using an old version of Selenium and IEDriver.

Download the latest version of Selenium and the IEDriverServer from here:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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