我们正在使用Selenium WebDriver测试一个应用程序。HTMLUnitDriver是我们的选择(因为非gui测试),有时IEDriver用于呈现目的。无论如何,我尝试单击一个按钮,这个按钮必须打开一个rich:popuPanel(modal=true)并单击该面板上的一个链接。对于IEDriver,这没有问题,但是对于HTMLUnitDriver,popupPanel不能打开。我试着用几种方法来执行这些点击:
JavascriptExecutor jsdriver = (JavascriptExecutor) driver;
jsdriver.executeScript("$('input[id$=freigabeCmd_id]').focus();");
//below are the other tries
// jsdriver.executeScript("$('input[id$=freigabeCmd_id]').click();");
// jsdriver.executeScript("window.document.getElementById('editorViewForm_id:freigabeCmd_id').click()");
// jsdriver.executeScript("arguments[0].click()", freigabeButton);
// jsdriver.executeScript("arguments[0].fireEvent('onclick');", freigabeButton);更进一步,我尝试了“正常的方式”:
freigabeButton.click();
//below are other ways i found here on stackoverflow
// freigabeButton.sendKeys(Keys.ENTER);
// new Actions(driver).moveToElement(freigabeButton).clickAndHold().release().build().perform();但我并不想让popupPanel变得“可见”。有人知道为什么吗?!我现在真的卡住了。如果您需要更多的信息,请让我知道。
使用: HTMLUnit版本2.12和最新的SeleniumVersion
发布于 2013-05-07 19:26:01
可能是您的webapp使用javascript来启动丰富的弹出式面板,而您在运行HtmlUnitDriver时禁用了javascript?它是disabled by default,所以需要显式启用它。
https://stackoverflow.com/questions/16399875
复制相似问题