-
-
Save kyleian/b049b066e787f2599063b21208b6d8bf to your computer and use it in GitHub Desktop.
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 & |
Is chromedriver working with Centos successfully ? Actually I am facing problems with chromedriver and Centos, it's throwing error "chromedriver failed to start".
@VDS2015 Yes, this has worked for me without any trouble in so far in booting chromedriver on a Centos node with the following setup.
Centos: CentOS Linux release 7.2.1511 (Core) for both Grid and Node machines
Chromedriver: 2.25 (haven't upgraded on it)
Protractor: 4.14
Node: 4.6
Selenium: 3.01
I recall hitting that error myself when I had bad locations for chrome/chromedriver and the path not pointing to the correct location. It may be worth getting a more contemporary version of chromedriver as well since the above script is now a little dated.
Chromedriver is not working when i run in jenkins
Jenkins runs on Centos7
Chromium 78.0.3904.108
version: Google Chrome 79.0.3945.88
location is /usr/bin/google-chrome
location /usr/bin/chromedriver
location chromium is under /usr/bin/chromium-browser
This is my code in eclipse
private void createDriver() {
// Set the Browser from Jenkins, if null, get it from Variables file
if (System.getenv("Browser") == null)
this.browser = Variables.browser;
else
this.browser = System.getenv("Browser");
// Set the operating system from Bamboo if not null
if (System.getenv("OperatingSystem") == null)
this.operatingSystem = Variables.operatingSystem;
else
this.operatingSystem = System.getenv("OperatingSystem");
if (Variables.isIE) {
// Set IE Driver path
System.setProperty("webdriver.ie.driver", "src/main/resources/IEDriverServer.exe");
// Initialize IE driver
Driver.driver.set(new InternetExplorerDriver());
// Maximize window
Driver.driver.get().manage().window().maximize();
}
else {
// New file to load chrome driver
File chromeDriver;
try {
chromeDriver = new File(System.getProperty("user.dir") + "/src/main/resources/chromedriver.exe");
// Set chrome properties
System.setProperty("webdriver.chrome.driver", chromeDriver.getAbsolutePath());
// Initialize chrome options
this.chromeProfile = new ChromeOptions();
//options.setExperimentalOption("useAutomationExtension", false);
// Initialize chrome options
chromeOptions = new HashMap<String, Object>();
Driver.driver.set(new ChromeDriver(chromeProfile));
}
catch (IllegalStateException e) {
chromeDriver = new File(System.getProperty("user.dir") +"/src/main/resources/chromedriver79");
//System.setProperty("webdriver.chrome.driver","/usr/bin/chromedriver");
// Set chrome driver to executable if it is not executable
if(!chromeDriver.canExecute())
chromeDriver.setExecutable(true);
// Set chrome properties
System.setProperty("webdriver.chrome.driver", chromeDriver.getAbsolutePath());
// Initialize chrome options
this.chromeProfile = new ChromeOptions();
// Initialize chrome options
chromeOptions = new HashMap<String, Object>();
System.out.println("Running on Linux machine");
Driver.driver.set(new ChromeDriver(chromeProfile));
options.addArguments("--no-sandbox");
options.addArguments("headless");
options.addArguments("--disable-gpu");
options.addArguments("--disable-dev-shm-usage");
}
// Maximize window
Driver.driver.get().manage().window().maximize();
eventFiringWebDriver.set(new EventFiringWebDriver(driver.get()));
EventHandler eventHandler = new EventHandler(getTestName());
eventFiringWebDriver.get().register(eventHandler);
capabilities.setCapability("screen-resolution", "1280x1024");
}
}
@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.
SeleniumHQ/selenium#2571
This issue with selenium 3 was my main problem, needing to switch where the chromedriver and chrome location arguments 'lived'