【问题标题】:Unable to select IE8 popup window using selenium RC无法使用 selenium RC 选择 IE8 弹出窗口
【发布时间】:2012-07-09 13:22:38
【问题描述】:

我正在尝试使用 Selenium RC 向 IE8 中的弹出窗口发送命令。

目前,我可以单击一个按钮并打开弹出窗口。

但是,我无法选择发送命令的窗口。

我已经对这个主题进行了大约一周的广泛研究,我相信这完全是一个 IE 问题。我找到了一些解决方法;一些博客已经指示用户打开一个空白窗口来“捕捉”命令。

但是,当我实现下面的代码时,会弹出一个空白窗口,单击打开弹出窗口的按钮后,会打开第三个窗口并加载我需要的页面。

我是否设置了不准确的目标?请参阅下面的 selenium rc 命令以及页面的 html 源代码。

Java 代码

selenium.runScript("selenium.browserbot.document.getElementByID(
              'ctl00_ContentPlaceHolder1_WebGroupBox1_btnAddRequirement').target='popup'"
);

selenium.openWindow("", "popup");

///Click on Add Requirement button
selenium.click("id=ctl00_ContentPlaceHolder1_WebGroupBox1_btnAddRequirement");

try { 
  Thread.sleep(2000);
} catch (InterruptedException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
}
selenium.selectWindow("popup");

添加要求按钮的 HTML

<input id="ctl00_ContentPlaceHolder1_WebGroupBox1_btnAddRequirement" 
       type="submit" 
       style="font-family:Arial,Times New Roman,Courier New;" 
       onclick="return validateProject();
                 WebForm_DoPostBackWithOptions(new  
                  WebForm_PostBackOptions(
                             "ctl00$ContentPlaceHolder1$WebGroupBox1$btnAddRequirement", 
                             "", 
                             true, 
                             "", 
                             "", 
                             false, 
                             false
                  )
                 )
                " 
       value="Add New Requirement" 
       name="ctl00$ContentPlaceHolder1$WebGroupBox1$btnAddRequirement"
>

【问题讨论】:

    标签: selenium internet-explorer-8 popup selenium-rc


    【解决方案1】:

    在WatiN(我知道的不同)中,我不得不发送alt+tab 和enter 的组合来处理弹出框。

    【讨论】: