How to change selenium-standalone port number via webdriverio wdio file?

Tags: , , ,



I need to change the port number of which selenium standalone server is using by default (4444). Port 4444 is currently in use, is there a way to alter the port number via the wdio file?

// Test runner services
// Services take over a specific job you don't want to take care of. They enhance
// your test setup with almost no effort. Unlike plugins, they don't add new
// commands. Instead, they hook themselves up into the test process.
services: ['selenium-standalone'],

Currently I’m starting selenium server via the following command:

./node_modules/.bin/selenium-standalone start

I have also attempting to use the following with no luck:

./node_modules/.bin/selenium-standalone start -port 7777

Running the above command still attempt to run selenium sever on port 4444.

Answer

To run the selenium-standalone on the specific port you should use the following syntax:

./node_modules/.bin/selenium-standalone start -- -port 7777

Change the port in the wdi.conf.js:

seleniumArgs: {
  seleniumArgs: ["-port", "7777"],
},

Also, read more about the wdio configuration file here and about wdio-cli here

So, your final wdio.conf.js should look like:

exports.config = {
  /**
  * server configurations
  */
  services: ['selenium-standalone'],
  port: 7777,
  seleniumArgs: {
    seleniumArgs: ["-port", "7777"],
  },
}


Source: stackoverflow