Marco Eckstein
Marco Eckstein

Reputation: 4758

Using Protractor with Firefox or IE

Protractor works fine with Chrome, but I cannot get it to start up Firefox or Internet Explorer.

Snippet from package.json:

"scripts": {
    ....
    "webdriver-manager-update": "webdriver-manager update --ie",
    "protractor": "protractor protractor.conf.js",
    ...
},
...
"devDependencies": {
    ...
    "protractor": "5.1.1",
    ...
}

protractor.conf.js:

exports.config = {
    capabilities: {
      browserName: "firefox" // or "internet explorer"
    },
    specs: ["target/e2e/**/*.e2e-spec.js"]
};

After running npm run webdriver-manager-update, <project-home>\node_modules\protractor\node_modules\webdriver-manager\selenium\ contains the files chromedriver_2.28.exe, geckodriver-v0.15.0.exe and IEDriverServer3.3.0.exe.

When running npm run protractor, I get an error:

[12:29:45] I/launcher - Running 1 instances of WebDriver
[12:29:45] I/local - Starting selenium standalone server...
[12:29:46] I/local - Selenium standalone server started at http://192.168.213.25:62661/wd/hub
[12:29:46] E/launcher - The path to the driver executable must be set by the webdriver.gecko.driver system property

(for IE, it refers to the webdriver.ie.driver system property)

After lots of googling, I tried the following fixes:

a) Add <project-home>\node_modules\protractor\node_modules\webdriver-manager\selenium\ to the system environment variable Path. This seems to make no difference.

b) Add the following line to protractor.conf.js:

seleniumArgs: ["-Dwebdriver.gecko.driver=<project-home>\\node_modules\\protractor\\node_modules\\webdriver-manager\\selenium\\geckodriver-v0.15.0.exe"],

Now npm run protractor yields:

[12:40:35] I/launcher - Running 1 instances of WebDriver
[12:40:35] I/local - Starting selenium standalone server...
[12:40:35] E/launcher - Error: Error: Server terminated early with status 1
    at Error (native)
    at earlyTermination.catch.e (<project-home>\node_modules\selenium-webdriver\remote\index.js:252:52)
    at process._tickCallback (internal/process/next_tick.js:103:7)
[12:40:35] E/launcher - Process exited with error code 100

(analoguous behavior with IE)

My search results suggest I am not the only one having this problem, but unfortunately, I did not discover a solution.

Upvotes: 4

Views: 3501

Answers (2)

craig
craig

Reputation: 5016

You could do this with a localSeleniumStandaloneOpts. The local driver option lets you start the selenium standalone server before the Protractor test, run the test, and finally takes down the server.

Another way you could do this is with webdriver-manager start --ie and the seleniumAddress in your configuration file. In your configuration file, you will set seleniumAddress: "http://127.0.0.1:4444/wd/hub".

A quick note about Firefox. Make sure that you are running the latest gecko driver and Firefox versions. If the Firefox tests are not running properly, look at the gecko driver github issues page.

Another note about Internet Explorer. You should use IE11 and the 32-bit driver version. If you look at the Protractor issues page, iedriver has been identified to have issues. I assume that these issues will not be fixed.

Upvotes: 1

Marco Eckstein
Marco Eckstein

Reputation: 4758

Finally I found the solution in an answer by Nick Tomlin:

Its is not seleniumArgs you need to set, but localSeleniumStandaloneOpts.jvmArgs. So, in protractor.conf.js, write:

localSeleniumStandaloneOpts: {
    jvmArgs: ["-Dwebdriver.gecko.driver=<project-home>\\node_modules\\protractor\\node_modules\\webdriver-manager\\selenium\\geckodriver-v0.15.0.exe"]
  },

(analoguous for IE)

Upvotes: 6

Related Questions