haotang
haotang

Reputation: 5738

Error when running cucumberjs ft. selenium, phantomjs, webdriverio

I already installed phantomjs globally npm install -g phantomjs

Started selenium with java -jar selenium-standalone-2.52.0.jar

Configure the World object for cucumberjs properly like this:

var options = {
    //desiredCapabilities: { browserName: 'internet explorer' }, // WORK
    //desiredCapabilities: { browserName: 'chrome' }, // WORK
    desiredCapabilities: { browserName: 'phantomjs' }, // NOT WORK
    waitforTimeout     : 2000,
    host: '127.0.0.1',
    port: 4444
};

this.browser = webdriverio.remote(options);

It worked with chrome & IE, but failed for phantomjs.

This is the error I got from Selenium console:

ERROR - org.apache.commons.exec.ExecuteException: Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program "C:\Program Files (x86)\nodejs\phantomjs" (in directory "."): CreateProcess error=193, %1 is not a valid Win32 application)

C:\Program Files (x86)\nodejs\phantomjs exists.

Do I miss any configuration for phantom / selenium?

Upvotes: 1

Views: 366

Answers (1)

haotang
haotang

Reputation: 5738

Well, finally I found the reason in this similar github issue.

C:\Program Files (x86)\nodejs\phantomjs only works for Linux system. Looks like the webdriver for phantomjs didn't check for the case of running on window application.

To quick-fix the problem, I remove the file C:\Program Files (x86)\nodejs\phantomjs, so selenium will automatically call phantomjs.bat on the same folder. Everything will work fine.

Upvotes: 1

Related Questions