Javascript is working after setting the option:
chromeOptions.addArguments("--enable-javascript");
But I am still looking on how to use widgetVar from PrimeFaces to get hold of a PrimeFaces widget.
I tried:
private static boolean isContentByWidgetVarProDriver(RemoteWebDriver driver, String driverName, String content, String widgetVar) {
WebElement value = null;
try {
value = (WebElement) driver.executeScript("return PF('domains_counter');", driver.findElement(By.id("main")));
if (value.getText().contains(content)) {
return true;
}
} catch (Exception e) {
LOGGER.info("Test failed on {}:nSelector was '{}' but value '{}' could not be read. '{}' was expected as content.", driverName, widgetVar, value, content);
}
return false;
}
But it returns null.
In the browser console it works.
2
Answers
Heureka!
This is the solution:
or in general: PrimeFaces.widgets.~~~
where ~~~ is the widgetVar of the widget!!!
This is what PrimeSelenium library does.