selenium-standalone icon indicating copy to clipboard operation
selenium-standalone copied to clipboard

Shutdown selenium server 3

Open geskill opened this issue 9 years ago • 4 comments

Hey, since version 3 the default behaviour to shutdown the selenium server has changed. The curl call to shutdown the server is now disabled by default. In order to activate the feature again, the server has to be started differently:

java -jar selenium-server-standalone-3.0.1.jar -role node -servlet org.openqa.grid.web.servlet.LifecycleServlet -registerCycle 0 -port 4444

See: https://github.com/seleniumhq/selenium/issues/2852

The -servlet org.openqa.grid.web.servlet.LifecycleServlet will enable the feature. But this command can not be set by the cli, therefore, some code needs to be added, i.e.

var servletArg = seleniumArgs.indexOf('-servlet');
var servlet = (servletArg !== -1) ? seleniumArgs[servletArg + 1] : undefined;

if (servletArg !== -1 && servlet !== undefined) {
  // ...
}

PR, ok?

geskill avatar Jan 31 '17 09:01 geskill

@geskill I don't think that any code change will be needed. In the README there is an example of how to provide extra arguments to the selenium process. Search for -role node if using CLI or opts.seleniumArgs if using the API.

Trying with selenium-standalone start -- -role node -servlet org.openqa.grid.web.servlet.LifecycleServlet -registerCycle 0 -port 4444 and then sending the shutdown request listed in issue you linked to gave me a clean exit for both the selenium node process and selenium-standalone.

stephenash avatar Jan 31 '17 21:01 stephenash

@stephenash, maybe you can help me to understand one thing. I'd like to run my e2e tests using npm script, for example:

"scripts": {
    "test:e2e": "wdio internals/tests/e2e/wdio.conf.js",

I'd like that after running "npm run test:e2e" script I would get:

  1. running selenium-server
  2. running wdio internals/tests/e2e/wdio.conf.js from my test:e2e script
  3. stopping selenium-server How can I get what I described using npm scripts?

pavel06081991 avatar Feb 11 '17 22:02 pavel06081991

@pavel06081991 You could try defining the pre<stage> and post<stage> commands for starting and stopping the selenium server. When you execute npm run test:e2e, npm will automatically call the pre- and post- stages for you as well.

  "scripts": {
    "pretest:e2e": "selenium-standalone start -- -role node -servlet org.openqa.grid.web.servlet.LifecycleServlet -registerCycle 0 -port 4444",
    "test:e2e": "wdio internals/tests/e2e/wdio.conf.js",
    "posttest:e2e": "curl -s 'http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer'"
  },

stephenash avatar Feb 16 '17 00:02 stephenash

@geskill Did my earlier suggestion fix the problems that you were running into? If not, please re-open this issue and we can explore more.

stephenash avatar Feb 16 '17 00:02 stephenash