简体   繁体   English

Selenium IEServerDriver找不到IE9的新窗口

[英]Selenium IEServerDriver not finding new windows for IE9

I am working with Selenium WebDriver to automate my companies site. 我正在与Selenium WebDriver合作,以自动化我的公司网站。 At one point, the web application opens a new window via the following: 有一次,Web应用程序通过以下方式打开一个新窗口:

<a onclick="WindowController.openWindow('quote.action?quoteProcessName=Shortform',WindowController.WINDOW_IS_TRACKED);" tabindex="1">Express Quote</a>

we are using jQuery, though I think this is custom. 我们正在使用jQuery,虽然我认为这是自定义的。 I am on the test team, and don't do any of the development of the site. 我在测试团队,并没有做任何网站的开发。 Anyway, it uses JavaScript to open a new window. 无论如何,它使用JavaScript打开一个新窗口。 After the script clicks this link, I need it to attach to the new window. 脚本单击此链接后,我需要它附加到新窗口。

The problem is that WebDriver doesn't seem to find the new window when running in IE9. 问题是WebDriver在IE9中运行时似乎没有找到新窗口。 Here's the code I am using to try and switch to the new window: 这是我用来尝试切换到新窗口的代码:

public boolean switchTo(final WebRobot robot, final String pageTitle) {
    boolean found = false;

    int count = 0;
    while (!found && count < 20) {
        final Set<String> handles = robot.getDriver().getWindowHandles();
        final Iterator<String> itr = handles.iterator();
        while (itr.hasNext()) {
            try {
                final String current = itr.next();
                robot.getDriver().switchTo().window(current);
                if (robot.getDriver().getTitle().contains(pageTitle)) {
                    robot.getLogger().debug("Switching to " + pageTitle);
                    found = true;
                }
            } catch (final NoSuchWindowException e) {
                count++;
                try {
                    Thread.sleep(2000);
                    System.out.println("Handles: " + robot.getDriver().getWindowHandles().size());
                } catch (final InterruptedException ignored) {
                    //Nothing to do here
                }
            }
        }
    }
    return found;
}

(WebRobot is a class that I wrote to allow me to easily switch browsers and execution modes with WebDriver. robot.getDriver() returns the Selenium WebDriver object.) (WebRobot是我编写的一个类,允许我使用WebDriver轻松切换浏览器和执行模式.robot.getDriver()返回Selenium WebDriver对象。)

After the new window opens, robot.getDriver().getWindowHandles().size() is always 1. Is there something I am missing to pick up the new window? 新窗口打开后,robot.getDriver()。getWindowHandles()。size()始终为1.是否有一些我缺少的东西来拿起新窗口?

This code works perfectly in Firefox, Chrome, and IE8, but not IE9. 此代码在Firefox,Chrome和IE8中完美运行,但不适用于IE9。 I am using the 64 bit edition of IEDriverServer, version 2.32.3.0. 我使用的是64位版本的IEDriverServer,版本2.32.3.0。 I am using Selenium WebDriver 2.32, and am running on Windows 7 64bit. 我使用的是Selenium WebDriver 2.32,我在Windows 7 64bit上运行。

http://grokbase.com/t/gg/webdriver/128hgbmcw0/getwindowhandles-return-only-1-window-in-ie http://grokbase.com/t/gg/webdriver/128hgbmcw0/getwindowhandles-return-only-1-window-in-ie

newSet.removeAll(oldSet); newSet.removeAll(oldSet); newWindow = newSet.toArray()[0]; newWindow = newSet.toArray()[0];

启用兼容模式解决了问题。

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

相关问题 Selenium Webdriver IE9事件未触发 - Selenium webdriver IE9 event not firing Selenium Sendkeys在IE9中第二次尝试失败 - Selenium Sendkeys fails to work in second attempt in IE9 Selenium / Java在Windows上无法与IE一起使用 - Selenium/ Java not working with IE on Windows Web窗口中的Oracle表单7 jinitiator不适用于IE9 - Oracle forms in web windows 7 jinitiator not working for IE9 如何使用Selenium在Windows 8上运行IE,并具有IE版本8的功能 - How to use Selenium run IE on Windows 8 with capabilities to IE version 8 在IE网页(SAP)上查找要用于Selenium Automation的元素时遇到问题 - Problems finding elements on IE webpage (SAP) to use for Selenium Automation Selenium IE Webdriver中的switchTo()之后查找元素的问题 - issue in finding element after switchTo() in Selenium IE Webdriver 我的IE9在后台运行时,Java中的硒测试无法运行 - Selenium tests in java doesn't run when my IE9 is running in background Selenium 2.32,Java 1.6.0_07,IE Webdriver(32和64位),IE9-getWindowHandles仅返回一个浏览器 - Selenium 2.32, Java 1.6.0_07, IE Webdriver (32 and 64 Bit), IE9 - getWindowHandles returns only one browser 使用IntelliJ IDEA IDE进行Selenium自动化处理IE9时遇到错误 - getting an error when opeming IE9 using IntelliJ IDEA IDE for Selenium automation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM