1

The objective is to hit a local version of GhostDriver, by leveraging the configuration of its path, that the Capabilities allow us to set: https://github.com/detro/ghostdriver/blob/master/README.md#what-extra-webdriver-capabilities-ghostdriver-offers

When running a test with Selenium webdriverjs like the trivial example:

var webdriver = require('selenium-webdriver');

var capabilities = webdriver.Capabilities.phantomjs();
capabilities.set('phantomjs.ghostdriver.path',
    '/Users/xyz/ghostdriver-master/src/main.js');

var driver = new webdriver.Builder().
    withCapabilities(capabilities).
    build();

driver.get('http://www.google.com');
driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');
driver.findElement(webdriver.By.name('btnG')).click();
driver.wait(function() {
    return driver.getTitle().then(function(title) {
        console.log(title);
    });
}, 1000);

driver.quit();

I am not able to hit my local version of GhostDriver. It just hits the default version which is baked into phantomjs.

However, if I use WebdriverIO using the same Capability definition:

var webdriverio = require('webdriverio');
var options = {
    desiredCapabilities: {
        'browserName': 'phantomjs',
        'phantomjs.ghostdriver.path':     '/Users/xyz/ghostdriver-master/src/main.js'
    },
    port: 4444
};
webdriverio
    .remote(options)
    .init()
    .url('http://www.google.com')
    .title(function(err, res) {
        console.log(res.value);
    })
    .end();

I am able to hit my local version of GhostDriver.

After looking at the documentation here: https://github.com/detro/ghostdriver/blob/master/README.md#what-extra-webdriver-capabilities-ghostdriver-offers

and other pages with similar issues, I was not able to find anything that worked.

versions used:

  • selenium-server-standalone v2.51.0
  • selenium-webdriver v2.48.2
  • webdriverio v4.0.2
  • phantomjs v2.1.1

Has anybody got an idea of how to get this working?

gkeyb2351
  • 11
  • 3
  • Have you tried debugging your webdriverjs to verify that the capabilities passed through the builder are what you expect? Also I get a syntax error with `capabilities.set(('phantomjs.ghostdriver.path', '/Users/xyz/ghostdriver-master/src/main.js');)` – Andrew Regan Feb 17 '16 at 21:33
  • Hi Andrew, you are right. When I wrote the sample, autocomplete must have added that extra set of parenthesis - which I removed. When I tried to debug, I did not see any differences. The same string was passed for both situations, which puzzles me, since the result should be the same. Hope you can make sense of this! Thanks in advance – gkeyb2351 Feb 17 '16 at 23:07

0 Answers0