Question

There appears to be an issue with ghostdriver in phantomjs that when an HTTP calls fails after clicking a button, the whole thing fails.

https://github.com/detro/ghostdriver/issues/202#issuecomment-19808784

The issue has been fixed and is in the main branch. Instructions are given on how to reference the new files and not use the ghostdriver as included with phantomjs.

The Java is here: https://github.com/detro/ghostdriver/issues/243

and there appears to be a value

  PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY

but that doesn't exist in C#

so have tried

  var opts = new PhantomJSOptions(); 
  opts.AddAdditionalCapability("phantomjs.ghostdriver.path.property", "c:\\path\\src\\main.js");

but no go, the output in the phantomjs still shows the older version


EDIT1: This is different to the path to phantomJS which can be setby

 PhantomJSDriverService.CreateDefaultService("c:\path\to\phantomjs.exe")

I am trying to tell phantomjs to use a localversion of Ghostdriver not the ghostdriver included within phantomjs iteself.


EDIT2: So digging around in the Java code files here https://github.com/detro/ghostdriver/blob/master/binding/java/src/main/java/org/openqa/selenium/phantomjs/PhantomJSDriverService.java

I found the code that sets the Java static string

 public static final String PHANTOMJS_GHOSTDRIVER_PATH_PROPERTY = "phantomjs.ghostdriver.path";

which implies I was setting it wrong above, but still this doesn't work when corrected

var opts = new PhantomJSOptions(); 
opts.AddAdditionalCapability("phantomjs.ghostdriver.path", "c:\\path\\src\\main.js");

getting warmer though.....

Was it helpful?

Solution

You're right, there's no way to do this in the currently released binary version of the .NET bindings. However, a change has just been made that will allow this. In the .NET bindings the code would look like the following:

var service = PhantomJSDriverService.CreateDefaultService(@"path\to\phantomjs.exe");
service.GhostDriverPath = @"path\to\ghostdriver\main.js";

var driver = new PhantomJSDriver(service);

The distinction between what is set via the PhantomJSDriverService and what is set via PhantomJSOptions can be summed up as follows. If the option is a command line argument to be passed into PhantomJS.exe, it should be set via the service; if it is an option for how GhostDriver acts, it should be set via the options class.

OTHER TIPS

You have at least two ways to specify phantomjs exec path.

Use static method in PhantomJSDriverService

var driver = new PhantomJSDriver(PhantomJSDriverService.CreateDefaultService("PHANTOMJSPATHHERE"));

Use the appopriate constructor of PhantomJSDriver (takes a string)

var driver = new PhantomJSDriver("PHANTOMJSPATHHERE");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top