How can I start InternetExplorerDriver using Selen

2019-03-20 12:03发布

I downloaded the driver and I gave the exact path in my code but when I ran the code it shows me error

my code with java is as below:

System.out.println("Internet Explorer is selected");
System.setProperty("webdriver.ie.driver","C:\\Program Files\\Selenium\\Drivers\\IEDriver\\IEDriverServer.exe");
driver = new InternetExplorerDriver();
selenium = new WebDriverBackedSelenium(driver, "http://www.datamoat.com/");

and the error message is

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: 1.15 seconds
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:15:02'
System info: host: 'SAKIB-PC', ip: '192.168.10.70', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_25'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver

13条回答
你好瞎i
2楼-- · 2019-03-20 12:18
import org.openqa.selenium.WebDriver;

import org.openqa.selenium.ie.*;

public class IEclass {



public static void main(String[] args) {

System.setProperty("webdriver.ie.driver","S:\\IE and Chrome ServerDriver\\IEDriverServer.exe");

WebDriver driver = new InternetExplorerDriver();

driver.get("https://www.google.com");
  }
    }
查看更多
甜甜的少女心
3楼-- · 2019-03-20 12:18

First download the exe file of the IEDriverServer (64 bit and 32 bit). Don't need to install, only download this file with your browser( 64 or 32 bit) and simply give the path of the exe file in the given code.

http://www.seleniumhq.org/download/

use this code

package myProject;

import org.openqa.selenium.ie.InternetExplorerDriver;

public class Browserlaunch {

    public static void main(String[] args) {

        System.setProperty("webdriver.ie.driver", "C:/Drivers/IEDriverServer.exe");
        InternetExplorerDriver IEDriver=new InternetExplorerDriver();
        IEDriver.get("http://localhost:8888");
    }
}
查看更多
我欲成王,谁敢阻挡
4楼-- · 2019-03-20 12:23

Below steps are worked for me, Hope this will work for you as well,

  1. Open internet explorer.
  2. Navigate to Tools->Option
  3. Navigate to Security Tab
  4. Click on "Reset All Zones to Default level" button
  5. Now for all option like Internet,Intranet,Trusted Sites and Restricted Site enable "Enable Protected" mode check-box.
  6. Set IE zoom level to 100%
  7. then write below code in a java file and run

    System.setProperty("webdriver.ie.driver","path of your IE driver exe\IEDriverServer.exe");
    InternetExplorerDriver driver=new InternetExplorerDriver();
    driver.manage().window().maximize();
    Thread.Sleep(10100);
    driver.get("http://www.Google.com");
    Thread.Sleep(10000);
    
查看更多
【Aperson】
5楼-- · 2019-03-20 12:24

I've been firefighting with this issue for the past one month. And finally I found a fruitful solution. Here are the exact steps which we followed to get it worked. I have already done Required Configuration as mentioned in this link: https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration

  1. Make the internet explorer protected mode settings enable/disable for all the zones. (In my case I enabled across all the zones, doesn't matter about the levels). If your organisation not allow these settings, the other solution is to create a group at active directory level and enforce our expected internet explorer settings for that group. Add your user name to that group.
  2. Install IE Webdriver tool for windows from the below link. This is from Microsoft. No need to restart your machine after installation https://www.microsoft.com/en-au/download/details.aspx?id=44069
  3. Use these Desired Capabilities for your internet explorer driver

    DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
    capabilities.setCapability("requireWindowFocus", true);  
    capabilities.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, false);
    capabilities.setCapability("ie.ensureCleanSession", true);
    

    capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); capabilities.setCapability(InternetExplorerDriver.FORCE_CREATE_PROCESS, true); webDriver = new InternetExplorerDriver(capabilities);

  4. Use appropriate selenium version 2.53.1. I got it worked for the selenium version as mentioned in pom

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.53.1</version>
    </dependency>
    
  5. Download the IEDriverServer_x64_2.53.1.zip from the below link. Make sure its 2.53.1 http://selenium-release.storage.googleapis.com/index.html?path=2.53/

  6. Now go to registry settings (regedit.exe) for the current user (Don't open regedit as an Administrator) and add TabProcGrowth for the below path in regedit

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main

Right click on Main and add new DWORD (32 bit) and make it as 0. Remember I tried 64 bit with QWORD it didn't worked for me.

The key in this process is Step 2 which is Install IE Webdriver tool for windows

I didn't tried this method for Selenium latest version 3.0 but will give a try.

查看更多
Viruses.
6楼-- · 2019-03-20 12:29

In c#, This can bypass changing protected zone settings.

var options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
options.ElementScrollBehavior = InternetExplorerElementScrollBehavior.Bottom;
查看更多
beautiful°
7楼-- · 2019-03-20 12:29

Go to Tools -> Internet Options -> Security and Enable protection mode for all zones. It worked for me :)

查看更多
登录 后发表回答