我想切换到单击图像时生成的jQuery模态窗口。然而Selenium(IE Webdriver)无法识别生成的模式窗口并且无法切换。没有异常/错误显示!Selenium IE Webdriver:无法切换到jQuery模态窗口
IE版本 - 11 硒版本 - 2.53 IE版本的webdriver - 2.53.1
我曾尝试切换代码:
objMovePage.clickFromAccountPicker(); //Image clicked
Thread.sleep(2000); //Wait for new window to show up
Set<String> windows = driver.getWindowHandles();
System.out.println(windows.size()); // This returns 1 always.
for(String handle: windows)
{
driver.switchTo().window(handle);
}
System.out.println(driver.getTitle()); //Prints current window title
我也曾尝试driver.switchTo().window("<window name>"); // This also doesn't work.
HTML代码被点击图片
<td style="height: 20px">
<input id="imgPickAcct" align="top" type="image" style="border-width:0px;" onclick="PickAcctClick(711269, 450, 300);" src="images/magnifyglass.gif" tabindex="-1" name="imgPickAcct">
</td>
JS功能码
function PickAcctClick(intTransmissionID, intwidth, intheight)
{
var lstrPath = 'wfrmGetTransmittedAccounts.aspx?TransmissionID=' + intTransmissionID;
var returnValues = openModal(lstrPath, intwidth, intheight);
if (returnValues != undefined)
{
document.forms[0].txtFromAccountingID.value = returnValues[0].toString();
document.forms[0].txtFromDept.value = returnValues[1].toString();
document.forms[0].txtFromAcct.value = returnValues[2].toString();
document.forms[0].txtFromCur.value = returnValues[3].toString();
document.forms[0].txtFromProduct.value = returnValues[4].toString();
if (isAnObject("txtFromChart1"))
{document.forms[0].txtFromChart1.value = returnValues[5].toString();}
if (isAnObject("txtFromChart2"))
{document.forms[0].txtFromChart2.value = returnValues[6].toString();}
if (isAnObject("txtFromChart3"))
{document.forms[0].txtFromChart3.value = returnValues[7].toString();}
}
return false;
}
注:这不是从在showModalDialog警告或对话窗口。 编辑:没有iFrame。
它在一个带有自己HTML代码的新窗口中打开。没有切换,我试图执行元素操作,得到NoSuchElementException – Haxor
这是一个真正的弹出?我怀疑你写了'System.out.println(windows.size()); //总是返回1。这强烈地表明没有创建新窗口。另外一个模式窗口不应该在新窗口中打开。如果您确定模式窗口是弹出窗口并且未被硒找到,请发布截图和/或html – samjaf
添加屏幕截图。 – Haxor