Home > other >  Is there anyway we can run the selenium scripts on jenkins server(linux) without installing the chro
Is there anyway we can run the selenium scripts on jenkins server(linux) without installing the chro

Time:09-24

I Have Maven project for selenium and i am using WebDriverManager which manages the chromdriver but when i run the tests on the jenkins server (Linux) it fails as it doesn't find the chrome browser(Not chromedriver) installed on the jenkins machine. Our Operation team is not willing to install the chromebrowser(Not chromedriver) on jenkins server and ask me to handle it someway in the project. Is there any way i can hanlde it in the project.

Note : Jenkins is fetching the project from Bitbucket repo

CodePudding user response:

Short answer: No, Selenium cannot run tests against Chrome without Chrome installed itself.

But you can make a few steps prior test run, which will download and install Chrome on a Linux machine via Terminal, like a test run pre-conditions.

It depends on your Linux distribution, but try smth like these general steps one by one:

1. sudo apt install wget
2. wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
3. sudo dpkg -i google-chrome-stable_current_amd64.deb
4. google-chrome

Firstly, it installs a tool for downloading apps via Terminal, then it downloads Chrome browser archive, then it installs Chrome itself and lastly, it runs Chrome to check whether it has installed correctly. (Last command is optional).

Now you're all set to run your Selenium tests!

CodePudding user response:

Headless mode does not expect actual browser to be installed in system. Make following changes in your configuration.

options = webdriver.ChromeOptions()
options.add_argument('--window-size=1920,1080')
options.add_argument("--headless")
options.add_argument("--start-maximized")
driver = webdriver.Chrome(executable_path = driver_path, options = options)
  • Related