<bdo id='Xchy0'></bdo><ul id='Xchy0'></ul>

        <legend id='Xchy0'><style id='Xchy0'><dir id='Xchy0'><q id='Xchy0'></q></dir></style></legend>

        <small id='Xchy0'></small><noframes id='Xchy0'>

        <i id='Xchy0'><tr id='Xchy0'><dt id='Xchy0'><q id='Xchy0'><span id='Xchy0'><b id='Xchy0'><form id='Xchy0'><ins id='Xchy0'></ins><ul id='Xchy0'></ul><sub id='Xchy0'></sub></form><legend id='Xchy0'></legend><bdo id='Xchy0'><pre id='Xchy0'><center id='Xchy0'></center></pre></bdo></b><th id='Xchy0'></th></span></q></dt></tr></i><div id='Xchy0'><tfoot id='Xchy0'></tfoot><dl id='Xchy0'><fieldset id='Xchy0'></fieldset></dl></div>
      1. <tfoot id='Xchy0'></tfoot>
      2. Selenium IEServerDriver 找不到 IE9 的新窗口

        时间:2023-07-13
          <bdo id='8a3vc'></bdo><ul id='8a3vc'></ul>
            <tbody id='8a3vc'></tbody>
        • <legend id='8a3vc'><style id='8a3vc'><dir id='8a3vc'><q id='8a3vc'></q></dir></style></legend>

              <small id='8a3vc'></small><noframes id='8a3vc'>

              <i id='8a3vc'><tr id='8a3vc'><dt id='8a3vc'><q id='8a3vc'><span id='8a3vc'><b id='8a3vc'><form id='8a3vc'><ins id='8a3vc'></ins><ul id='8a3vc'></ul><sub id='8a3vc'></sub></form><legend id='8a3vc'></legend><bdo id='8a3vc'><pre id='8a3vc'><center id='8a3vc'></center></pre></bdo></b><th id='8a3vc'></th></span></q></dt></tr></i><div id='8a3vc'><tfoot id='8a3vc'></tfoot><dl id='8a3vc'><fieldset id='8a3vc'></fieldset></dl></div>

              • <tfoot id='8a3vc'></tfoot>

                  本文介绍了Selenium IEServerDriver 找不到 IE9 的新窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 Selenium WebDriver 来自动化我的公司网站.在某一时刻,Web 应用程序通过以下方式打开一个新窗口:

                  I am working with Selenium WebDriver to automate my companies site. At one point, the web application opens a new window via the following:

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

                  我们正在使用 jQuery,尽管我认为这是自定义的.我在测试团队,不做任何网站的开发.无论如何,它使用 JavaScript 打开一个新窗口.脚本单击此链接后,我需要将其附加到新窗口.

                  we are using jQuery, though I think this is custom. 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. After the script clicks this link, I need it to attach to the new window.

                  问题是 WebDriver 在 IE9 中运行时似乎没有找到新窗口.这是我用来尝试切换到新窗口的代码:

                  The problem is that WebDriver doesn't seem to find the new window when running in 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 是我编写的一个类,它允许我使用 WebDriver 轻松切换浏览器和执行模式.robot.getDriver() 返回 Selenium WebDriver 对象.)

                  (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.)

                  新窗口打开后,robot.getDriver().getWindowHandles().size() 始终为1.是不是我缺少什么东西才能拿起新窗口?

                  After the new window opens, robot.getDriver().getWindowHandles().size() is always 1. Is there something I am missing to pick up the new window?

                  此代码在 Firefox、Chrome 和 IE8 中完美运行,但在 IE9 中无法正常运行.我正在使用 IEDriverServer 的 64 位版本,版本 2.32.3.0.我正在使用 Selenium WebDriver 2.32,并在 Windows 7 64bit 上运行.

                  This code works perfectly in Firefox, Chrome, and IE8, but not IE9. I am using the 64 bit edition of IEDriverServer, version 2.32.3.0. I am using Selenium WebDriver 2.32, and am running on Windows 7 64bit.

                  推荐答案

                  打开兼容模式解决了这个问题.

                  Turning on Compatibility Mode fixed the issue.

                  这篇关于Selenium IEServerDriver 找不到 IE9 的新窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用 Selenium WebDriver 运行 TOR 浏览器 下一篇:Selenium:如何判断 RemoteWebDriver.findElements(By) 是否可以抛出 StaleE

                  相关文章

                  • <bdo id='4McAv'></bdo><ul id='4McAv'></ul>
                1. <legend id='4McAv'><style id='4McAv'><dir id='4McAv'><q id='4McAv'></q></dir></style></legend>

                  <small id='4McAv'></small><noframes id='4McAv'>

                2. <i id='4McAv'><tr id='4McAv'><dt id='4McAv'><q id='4McAv'><span id='4McAv'><b id='4McAv'><form id='4McAv'><ins id='4McAv'></ins><ul id='4McAv'></ul><sub id='4McAv'></sub></form><legend id='4McAv'></legend><bdo id='4McAv'><pre id='4McAv'><center id='4McAv'></center></pre></bdo></b><th id='4McAv'></th></span></q></dt></tr></i><div id='4McAv'><tfoot id='4McAv'></tfoot><dl id='4McAv'><fieldset id='4McAv'></fieldset></dl></div>
                    <tfoot id='4McAv'></tfoot>