简体   繁体   English

使用Java的Internet Explorer上运行Selenium 2.12失败

[英]Running Selenium 2.12 fails on Internet Explorer with Java

I have just installed the latest version of Selenium 2.12. 我刚刚安装了最新版本的Selenium 2.12。

I am trying to run the following java program using Selenium on IE. 我正在尝试在IE上使用Selenium运行以下Java程序。 But unfortunately it's not working. 但是不幸的是它没有用。

sample program 样例程序

Here is the error message. 这是错误消息。

May 24, 2012 7:12:50 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
Exception in thread "main" org.openqa.selenium.UnhandledAlertException: Modal dialog present (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 849 milliseconds
Build info: version: '2.21.0', revision: '16552', time: '2012-04-11 19:08:38'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_04'
Driver info: driver.version: InternetExplorerDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:175)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:134)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:459)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:140)
    at org.openqa.selenium.ie.InternetExplorerDriver.setup(InternetExplorerDriver.java:113)
    at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:66)
    at ExampleProgram.main(ExampleProgram.java:13)

This is launching the IE 8 with the URL " http://localhost:15194/ " and showing the content - This is the initial start page for the WebDriver server. 这将使用URL“ http://localhost:15194/ ”启动IE 8并显示内容- This is the initial start page for the WebDriver server.

Please help me with what I'm doing wrong here. 请帮我解决我在这里做错的事情。 I have done the basic setup as mentioned in wiki 我已经完成了维基中提到的基本设置

Just a small correction, the latest version is 2.21 and not 2.12. 只是一个小的更正,最新版本是2.21,而不是2.12。

Start your scripts with this 以此开始脚本

driver = Selenium::WebDriver.for :ie, :switches => %w[--ignore-certificate-errors --disable-popup-blocking --disable-translate]

Open your browser as an Admin, and change settings in Internet Options to allow popups and also keep "Protected Mode"disabled. 以管理员身份打开浏览器,然后在“ Internet选项”中更改设置以允许弹出窗口,并同时禁用“保护模式”。

Apart from that, I guess the modal message could also be because there might be some insecure content that is being displayed on a https site. 除此之外,我猜想模态消息也可能是因为https站点上可能显示了一些不安全的内容。

So to avoid that the message from being displayed, also perform the following steps 因此,为避免显示该消息,请执行以下步骤

  • IE-> Open as Admin IE->以管理员身份打开
  • Go to Internet Options 转到Internet选项
  • Go to Security tab 转到安全选项卡
  • Click on Custom Level button 单击自定义级别按钮
  • Under Miscellaneous - Enable Mixed content 在其他下-启用混合内容

if this does not solve the issue, please share the exact message that is displayed on the modal popup. 如果这样做不能解决问题,请共享模态弹出窗口上显示的确切消息。 Hope this helps 希望这可以帮助

在安装新的IE版本-9之后,这对我有用。

You have to download "IEDriverServer_Win32_2.29.0.zip". 您必须下载“ IEDriverServer_Win32_2.29.0.zip”。 Extract it to a target folder and instantiate the Internet Explorer browser as below: 将其解压缩到目标文件夹并实例化Internet Explorer浏览器,如下所示:

File file = new File("E:\\Global Blue\\globalblue-selenium-test\\gb-selenium-test\\lib\\IEDriverServer_Win32_2.29.0\\IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
WebDriver oWebDriver = new InternetExplorerDriver();

Try using: 尝试使用:

Thread.sleep(3000);

It worked for me. 它为我工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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