无法在Selenium WebDriver中启动IE浏览器 [英] Unable to launch IE browser in selenium webdriver

查看:392
本文介绍了无法在Selenium WebDriver中启动IE浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了示例代码来启动IE browser并加载Google页面.

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

但是,当我运行此脚本时,它将启动浏览器,并且它会立即关闭(少于2秒),而不会提示任何错误,并且脚本不会终止.

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:

启动InternetExplorerDriver服务器(32位)

Started InternetExplorerDriver server (32-bit)

2.53.1.0

在端口46974上监听

Listening on port 46974

仅允许本地连接

有人可以帮助我解决这个问题吗?

Can any one help me on this issue?

推荐答案

要在IE中执行代码,需要为浏览器设置一些安全设置: 1)打开IE 转到工具-选择Internet选项-选择安全性 将所有区域(Int​​ernet,本地Internet,受信任的站点,受限制的站点)设置为相同的保护模式(无论启用还是禁用) 2)将缩放比例设置为100%:在iE浏览器的右上角选择设置符号.选择缩放.将缩放比例设置为100%(无论您想要什么,例如125,200等),关闭IE. 3)如果您要查看要显示在页面上的缩放比例,请执行以下操作: 在浏览器的右上角,右键单击您将获得一些选项,启用状态栏.然后,您将可以在页面的右下方看到缩放比例.

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.

这篇关于无法在Selenium WebDriver中启动IE浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆