我们在Primefaces中有一个数据表,其中有复选框。在运行 Selenium Webdriver test for Firefox 复选框时,即使该元素在浏览器中可见,我们也会出现 ElementNotVisible 异常。此测试在 IE 中正常运行。请让我知道可能是什么问题。下面给出的是素数和硒测试的代码:-
硒测试用例
@Test
public void testGroupViewButton()
{
try {
logger.info("Method testGroupViewButton");
WebElement searchResultsDataTableElement = commonTest.findElementById("carTable");
logger.info(" searchResultsDataTableElement "+searchResultsDataTableElement.isDisplayed());
List<WebElement> dataRows=searchResultsDataTableElement.findElements(By.className("ui-widget-content"));
logger.info("dataRows "+dataRows.size());
WebElement chkBoxElement;
//wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.name(checkBoxName)));
for(int i=0;i<1;i++)
{
commonTest.waitUntilElementLoads();
System.out.println("Check Box is "+dataRows.get(i).findElement(By.tagName("input")));
System.out.println("Check Box is displayed "+dataRows.get(i).findElement(By.tagName("input")).isDisplayed());
chkBoxElement = dataRows.get(i).findElement(By.name("carTable_checkbox"));
System.out.println("chkBoxElement "+chkBoxElement);
System.out.println("chkBoxElement "+chkBoxElement.isDisplayed());
}
} catch (Exception e) {
e.printStackTrace();
logger.trace(e);
}
}
JSF 代码:-
<ui:composition template="template/common/commonPrimefacesLayout.xhtml">
<ui:define name="content">
<p:button value="Test" onclick="checkVisibilityOfCheckBox()"></p:button>
<p:dataTable var="car" value="#{tableBean.cars}" paginator="true" rows="10" rowKey="#{car.id}" selection="#{tableBean.selectedCars}" id="carTable">
<f:facet name="header">
Checkbox Based Selection
</f:facet>
<p:column selectionMode="multiple" style="visibility: visible;width:20%;height:20%" />
<p:column headerText="Model">
<h:outputText value="#{car.brand}" />
</p:column>
</p:dataTable>
</ui:define>
</ui:composition>
我在这个问题上遇到了令人沮丧的问题。最后我使用:
JavascriptLibrary jsLib = new JavascriptLibrary();
jsLib.callEmbeddedSelenium(driver,"triggerMouseEventAt", editButton,"click", "0,0");
editButton 是一个 WebElement