Suraj
Suraj

Reputation: 61

Unable to launch IE browser in selenium webdriver

I have written a sample code to launch IE browser and load google page.

public class Sample {

 public static void main(String[] args) 
  {
    // TODO Auto-generated method stub
    System.setProperty("webdriver.ie.driver","H:/IEDriverServer.exe");
    WebDriver driver=new InternetExplorerDriver();
    driver.manage().window().maximize();
    driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);

    driver.get("http://www.google.com");
  }
}

But when I run this script it launches browser and it gets closed immediately (less than 2 sec) without prompting any error and the script wont terminates.

This is what I can see on console screen:

Started InternetExplorerDriver server (32-bit)

2.53.1.0

Listening on port 46974

Only local connections are allowed

Can any one help me on this issue?

Upvotes: 6

Views: 32112

Answers (7)

Alex
Alex

Reputation: 143

Disabled JavaScript on IE can cause the test to not run.

I keep reading answers to set security setting to anything as long as it's consistent, but I find it's best to set them all to Medium, as this security level won't disable JavaScript. But in any case, if one has this issue, he can choose "Custom level..." for the "Internet" option in the Security tab, and make sure that "Active Scripting" under "Scripting" is enabled.

Of course, first make sure to complete all the steps in the IEDriver docs.

Upvotes: 0

kiranmai
kiranmai

Reputation: 31

To execute your code in IE need to set some security setting for your browser: 1) open IE Goto tools-- select internet options-- select security Set all zones (Internet , local internet,Trusted sites,Restricted sites) to the same protected mode(enabled or disabled is no matter) 2) set the zoom to 100% : In iE browser at top right hand side corner select settings symbol. select zoom . set zoom to 100% (what ever you want like 125,200 etc) close IE. 3) If you want to see the zoom to display on the page: On the top right hand side of the browser just right click you will get some options , enable the status bar. Then you will be able to see the zoom at the rightside bottom of the page.

Upvotes: 2

kiranmai
kiranmai

Reputation: 31

I completely agree with sandeep's solution along with that for setting zoom level to 100% permanently i am adding few code lines as i faced issue to set this.

These are the code lines i found after i browsed for the zoom level 100% error:

System.setProperty("webdriver.ie.driver", "C:/Drivers/IEDriverServer.exe");
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability("ignoreZoomSetting", true);
driver= new InternetExplorerDriver(capabilities);           
driver.manage().window().maximize();

For the security settings to execute code through IE : follow the steps in this link.` 'http://www.seleniumeasy.com/selenium-tutorials/how-to-run-webdriver-in-ie-browser'

Hope this solution helps you.... :)

Upvotes: 0

user7411924
user7411924

Reputation: 1

package tests;

import java.util.concurrent.TimeUnit;

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

public class Sample {

    public static void main(String[] args) {
        System.setProperty("webdriver.ie.driver","C:\\Automation Workspace\\ComplianceDashboardProject\\Vendor\\IEDriverServer.exe");
        WebDriver driver=new InternetExplorerDriver();
        driver.manage().window().maximize();
        driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);

        driver.get("http://www.google.com");
        driver.quit();
    }
}

I did the above and got it to work. Maybe try moving your driver file to another location to make sure there isn't some security issue.

Upvotes: 0

Saurabh Gaur
Saurabh Gaur

Reputation: 23835

If your IE version is 11, There are following steps to resolve it :-

  • Registry entries for 32 and 64 bit.

create a DWORD value with the name "iexplore.exe" and the value of 0 in the following key

for 32-bit Windows :- HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE

for 64-bit Windows :- HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE
  • Adjusted "Protected Mode" to be the same for all security zones by navigating through Settings -> Internet Options -> Security
  • Unchek "Enable Protected Mode" for all zones
  • Even rebooted.

If still getting the problem Add domain to list of "Trusted Sites" for i.e. in "Internet Options" (https to trusted sites, and http to local intranet).

Hope it will help you..:)

Upvotes: 0

Leon Barkan
Leon Barkan

Reputation: 2703

try:

public static void main(String[] args) 
{
    try
    {
       string path = @"H:\IEDriverServer.exe";
       WebDriver driver = new InternetExplorerDriver(path);
       driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
       driver.manage().window().maximize();

       driver.get("http://www.google.com");
    }
    catch(Exception ex)
    {
    }
}

Upvotes: 0

Sandeep
Sandeep

Reputation: 41

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. Now for all option like Internet,Intranet,Trusted Sites and Restricted Site enable "Enable Protected" mode check-box.
  5. Set IE zoom level to 100%
  6. Click on Apply and OK
  7. Close the IE browser and run your script

Upvotes: 2

Related Questions