Skip to content

Instantly share code, notes, and snippets.

@kyleian
Last active January 15, 2020 19:14
Show Gist options
  • Save kyleian/b049b066e787f2599063b21208b6d8bf to your computer and use it in GitHub Desktop.
Save kyleian/b049b066e787f2599063b21208b6d8bf to your computer and use it in GitHub Desktop.
Selenium Node on CentOS with Chrome script
sudo su
#Get Chromedriver and Selenium from net.
wget -P /opt/chromedriver/ "https://chromedriver.storage.googleapis.com/2.25/chromedriver_linux64.zip"
wget -P /opt/selenium/ "http://selenium-release.storage.googleapis.com/3.0/selenium-server-standalone-3.0.1.jar"
wget -P /opt/ "http://download.oracle.com/otn-pub/java/jdk/8u111-b14/jdk-8u111-linux-x64.tar.gz"
#Build out chrome repo
cat << EOF > /etc/yum.repos.d/google-chrome.repo
[google-chrome]
name=google-chrome - \$basearch
baseurl=http://dl.google.com/linux/chrome/rpm/stable/\$basearch
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
EOF
#Install required elements for selenium node.
yum -y install java-1.8.0-openjdk google-chrome-stable unzip
unzip /opt/chromedriver/chromedriver_linux64.zip -d /opt/chromedriver
#Ensure selenium has appropriate chrome paths.
export PATH="/opt/chromedriver/:$PATH"
#Xvfb required - Mac will look into this via Xquartz
yum -y install Xvfb
Xvfb :99 &
export DISPLAY=:99
#SELENIUM SG in AWS configured should take care of this already, so if you set it manually might be redundant.
#iptables -I INPUT -p tcp --dport 4444 -j ACCEPT
#iptables -I INPUT -p tcp --dport 5555 -j ACCEPT
#Make sure you're running the jar while not super user
exit
#Kick off Selenium Node.
nohup java -jar -Dwebdriver.chrome.driver=/opt/chromedriver/chromedriver -Dwebdriver.chrome.bin=/opt/google/chrome/google-chrome /opt/selenium/selenium-server-standalone-3.0.1.jar -role node -hub http://%YOUR_GRIDS_IP:4444/grid/register/ -log node.log &
@kyleian
Copy link
Author

kyleian commented Jan 15, 2020

@HarikaVegesna The initial script is nearly 3 years old, I'm positive there are newer versions of selenium and chromedriver.
You also haven't provided anything indicating an error, and the code you provide is not an issue with the script in this gist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment