Unable to launch IE browser in selenium webdriver

2020-02-26 11:47发布

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?

7条回答
狗以群分
2楼-- · 2020-02-26 12:39

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.

查看更多
登录 后发表回答