Senči
Senči

Reputation: 941

Selenium WebDriverJs is unable to create a new client with iOS

I am trying to use Selenium WebDriverJS with the iOS browser. Unfortunately this doesn't work as I need it to do.

I've set up the "iWebDriver"-Project like described at the iPhoneDriver wiki page. I've copied the python script and it worked. Even a small nodeJS project worked, but when I tried to run it from the Browser Firefox gives me the following Error message.

Error: Unable to create a new client for this browser. The WebDriver session ID has not been defined.

The Code I'm trying to run:

var driver = new webdriver.Builder().
    usingServer('http://localhost:3001/wd/hub').
    withCapabilities({'browserName': 'iPhone'}).
    build();

driver.get('http://www.google.com');
driver.quit();

I've compiled webdriverjs like discribed at the WebDriverJs wiki page. And yes, webdriver.js is loaded ;)

Upvotes: 2

Views: 1182

Answers (2)

byoungb
byoungb

Reputation: 1801

So I dug in and I think I have a solution. It seems like a hack but for firefox, and the firefox extension that I am making it works perfectly fine so far.

I edited the webdriver.js file's webdriver.Builder.prototype.build as so

webdriver.Builder.prototype.build = function() {
  var a;
//  if(webdriver.FirefoxDomExecutor.isAvailable()) {
//    return a = new webdriver.FirefoxDomExecutor, webdriver.WebDriver.createSession(a, this.getCapabilities())
//  }
  a = new webdriver.http.CorsClient(this.getServerUrl());
  a = new webdriver.http.Executor(a);
//  if(this.getSession()) {
//    return webdriver.WebDriver.attachToSession(a, this.getSession())
//  }
//  throw Error("Unable to create a new client for this browser. The WebDriver session ID has not been defined.");
  return webdriver.WebDriver.createSession(a, this.getCapabilities());
};

Basically I am forcing it to create a session, not sure why FirefoxDomExecutor was required since it works just fine on firefox and chrome with changes that I made. Anyway thanks for getting me on the right track, and hopefully this will help others.

Upvotes: 2

Senči
Senči

Reputation: 941

It seems like WebDriverJS is not capable of creating a new Session when not running in Node.js.

You have to create a Session manually and provide WebDriverJS with the session-id as the wdsid GET-Parameter (e.g. urltowebdriver.html?wdsid=someID&wdurl=localhost:9000).

Upvotes: 1

Related Questions