Vanshika Saini
Vanshika Saini

Reputation: 9

How can we install chrome in Jenkins (via openshift 4)

I wanted to run an automation testing script(written in java) on jenkins(Red Hat Enterprise Linux release 8.7), that has these specifications: System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.14.0-284.64.1.el9_2.x86_64', java.version: '11.0.18'

First I tried to download linux chromedriver from this link: https://googlechromelabs.github.io/chrome-for-testing/#stable

And I did following changes in my Drivers.java file

package com.airbus.iam.l10.datacheckerautomationtesting.factory;

import org.openqa.selenium.PageLoadStrategy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Drivers {
    static WebDriver driver=null;

    public  static void initializeBrowser(String browserName){

        System.setProperty("webdriver.chrome.driver", "chromedriver");
        ChromeOptions options = new ChromeOptions();
//        options.addArguments("--headless");
        options.addArguments("--window-size=1920,1080");
        options.addArguments("--start-maximized");
        options.addArguments("--incognito");

        options.setPageLoadStrategy(PageLoadStrategy.NORMAL);

        if(browserName.equals("chrome")){
                driver = new ChromeDriver(options);

            }
            else if (browserName.equals("edge")){
                driver = new EdgeDriver();
            }
            else if (browserName.equals("firefox")){
                driver = new FirefoxDriver();
            }
    }

    public static WebDriver getDriver(){
        return driver;
    }
}

But I am still getting this error:

org.openqa.selenium.remote.NoSuchDriverException: chromedriver located at chromedriver, cannot be executed
For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location/
Build info: version: '4.11.0', revision: '040bc5406b'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.14.0-284.64.1.el9_2.x86_64', java.version: '11.0.18'
Driver info: driver.version: ChromeDriver

Also I do not have chrome installed in my linux server

Then I tried downloading chrome using openshift4 terminal using this article: How can I run selenium on Linux?

It shows sudo command not found in terminal when I try to install chrome binary.

And for chrome driver, it takes very long time and it shows: Connecting to dl.google.com (dl.google.com)|142.250.201.174|:443... connected. The terminal connection has closed.

Please suggest a way to solve this issue.

Upvotes: 0

Views: 77

Answers (1)

Shawn
Shawn

Reputation: 8563

System.setProperty("webdriver.chrome.driver", "chromedriver");

You need to provide full absolute path of the chromedriver in above code.

Suggestion: If you are using selenium v4.6.0 or higher, you don't need to download and set the chrome driver path manually anymore. Which means you don't need the above code. Just delete it.

Selenium's new tool known as Selenium Manager will do the automatic driver management.

References:

Upvotes: 0

Related Questions