skip to Main Content

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.

browser console

2

Answers


  1. Chosen as BEST ANSWER

    Heureka!

    This is the solution:

    driver.executeScript("return PrimeFaces.widgets.domains_counter_panel.content[0].innerText");
    

    or in general: PrimeFaces.widgets.~~~

    where ~~~ is the widgetVar of the widget!!!


  2. This is what PrimeSelenium library does.

     public static String getWidgetByIdScript(String id) {
            return "PrimeFaces.getWidgetById('" + id + "')";
        }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search