Is it possible to execute Javascript in the context of a page with Conductor Selenium framework?

206 Views Asked by At

I am using Conductor to control PhantomJS via Selenium/Webdriver. PhantomJS has a function evaluateJavascript.

Is it possible to execute Javascript in the context of a page with Conductor? If so, how?

1

There are 1 best solutions below

0
Tim On

I have not tried it, but I came across a similar problem with HtmlUnit.

I solved it by checking out the conductor framework GitHub project and I modified the Locomotive constructor to get the WebClient from the WebDriver. So you could try to cast the WebDriver to PhantomJSDriver and then access the internal methods like "executeScript", "executePhantomJS":

 case PHANTOMJS:
        capabilities = DesiredCapabilities.phantomjs();
        if (isLocal)
          try {
            driver = new PhantomJSDriver(capabilities);

            // Cast to PhantomJSDriver
            ((PhantomJSDriver)driver).executeScript(...)

          }