Does Selenium Grid (v4) have a shutdown command when running as standalone (without -role option)?
I do not want to use kill commands, I know that I can do lsof -t -i :4444 | xargs kill, but I would like to avoid that
Related
I'm was wondering how can I pass a different port number as argument when I'm running the selenium container instead of the default port(4444)
Usually I'm using:
docker run --shm-size=2G -d --net=host -e TZ=UTC -e SCREEN_WIDTH=1920 -e SCREEN_HEIGHT=1080 selenium/standalone-chrome:3.7.0
Is it possible to do so with the current selenium image or do I need to build a selenium image of my own and if so how to create that kind of image?
You can bind port with -p
docker run -d -p 4444:4444 --name selenium-hub selenium/hub:3.8.1-aluminum
But if you want change the port inside container I think you must modify sources of image.
Not sure if this works with your docker image, it might help if you try to build your own image.
Use this image from GitHub
https://github.com/SeleniumHQ/docker-selenium/tree/master/StandaloneChrome
Open entrypoint.sh and edit
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server-standalone.jar -role hub -port (custom port no.)
Then in dockerfile change EXPOES (custom port)
Then build docker again
The command I'm using to start the Appium server:
node appium --address 127.0.0.1 --port 4723 --session-override --no-reset --platform-name Android --platform-version 23 --automation-name Appium
How would I stop the server through command line?
Ctrl+c
or
Run pkill -9 -f appium in the Terminal.
If you're looking to do this programmatically, see http://discuss.appium.io/t/launching-and-stopping-appium-server-programmtically/700.
If you have a lot of instances of appium running and don't want to stop them one at a time then try the following command it will close all of htem at once:
/usr/bin/killall -KILL node
run ps -A | grep appium to see how many processes are there and if there are too many then the command aobve comes to had.
I tryied command from older versions, but it dont seems to work.
curl "http://localhost:5555/selenium-server/driver/?cmd=shutDownSeleniumServer"
'Old' command is not working because it's part of selenium RC which is not included in selenium 3.
You should now start your nodes with -servlet org.openqa.grid.web.servlet.LifecycleServlet included, and than you can shut it down with http://yourNodeIP:port/extra/LifecycleServlet?action=shutdown
I reported this issue few months ago and it's solved so you can check it out for more details here. https://github.com/SeleniumHQ/selenium/issues/2982
If you are on linux you can kill the process running on that port by
fuser -k 5555/tcp
or netstat -plten |grep java you will get the PID of seleniumserver process.
kill -9 PID.
Also try hitting the lifecycle of selenium grid2
http://yourHubIP:port/lifecycle-manager?action=shutdown
CTRL+c from your terminal also would help.
let me know if you are looking for anything else
Assuming you are running it on *nix and the standalone server is listening on the default port (4444)... you need to:
find the PID of the process that is bound to port 4444 (use lsof command)
send that process a SIGTERM to gracefully shutdown (use the kill command)
you can achieve this with the following one-liner:
$ lsof -t -i :4444 | xargs kill
I'm using Docker to running automated browser testing using nightwatch.js
When I open an interactive terminal it works fine, e.g.
docker run -it --rm username/image-name /bin/bash
that gives me a bash prompt and I run:
xvfb-run node nightwatch.js
and everything works fine.
But when I run:
docker run --rm username/image-name xvfb-run node nightwatch.js
It just hangs.
What's the difference between opening a bash terminal and manually running the test command, and just running the test command directly? Surely they should both work?
Ok so I still don't know what is causing this issue, but I have a workaround that works quite well:
Run bash as a daemon:
CONTAINERID=$(docker run -it -d username/image-name /bin/bash)
Then use docker exec:
docker exec $CONTAINERID xvfb-run node nightwatch.js
Of course you will need to do some tidying up afterwards:
docker stop $CONTAINERID
docker rm $CONTAINERID
I'm using Selenium RC in a Ubuntu system.
I want to automate the tests, and I need to start Selenium-server.jar on startup of the machine.
I created seleniumServer.conf in /ect/init/ with:
start on startup
start on runlevel 3
respawn
exec xvfb-run java -jar /home/condde/selenium-server-1.0.3/selenium-server.jar -port 4444
When I reboot the machine, it works fine, the process is running.
But when I execute a test, the result is:
PHPUnit_Framework_Exception: Could not connect to the Selenium RC server.
Any ideas?
Thanks!
I have the same problem, my process can not connect the selenium server sometimes. After dig into debug log and selenium source code, I found that's because java's SecureRandom hangs if /dev/random hangs when selenium try generate random number. So I replace /dev/random with /dev/urandom, then selenium server works fine:
sudo mv /dev/random /dev/random.real
sudo ln -s /dev/urandom /dev/random
Or you can modify $JAVA_HOME/jre/lib/security/java.security file and changing the property:
securerandom.source=file:/dev/random
to:
securerandom.source=file:/dev/urandom
Maybe it works, but not for me.
Use -debug to start Selenium with debug log to see if any error.
java -jar selenium-server.jar -debug > /var/log/selenium-server.log 2>&1
I did this on ubuntu 14 using npm.
First, install the selenium-standalone via npm.
sudo npm install selenium-standalone -g
sudo selenium-standalone install
Then create a symbolic link in /etc/init.d, and configure it to run.
sudo ln -s /usr/local/bin/selenium-standalone /etc/init.d/
sudo update-rc.d selenium-standalone defaults
Another very simple and good solution is to install selenium via docker. I have used the chrome image and it's easy as:
sudo docker run -d -p 4444:4444 selenium/standalone-chrome
The -d option makes is a daemon that will be restarted every time you start your computer. The -p option forwards the webdriver port (4444) from the docker instance to the host.
Well, it's not phantomjs, but I like chrome better anyway. There is also a firefox image! Checkout https://github.com/SeleniumHQ/docker-selenium for more info.
I would start the selenium server process with -log parameter to get info from the process first and all and see if it actually get any kind of connections, errors etc..
A few ideas to troubleshoot:
Do you get any response if you enter http://localhost:4444
It should render a 403 error by the Jetty engine.
If this does not work I would try with your actual IP:4444, that might indicate problem with localhost variable, proxy settings etc..
Could the firewall settings be blocking the the 4444 port? Maybe the Selenium Server process is not allowed to start the browser.