Reputation: 764
I am running git lab ci cd pipeline for selenium Python UI automated tests. My tests are passing ok on my local. I have initialized Google Chrome using below code
driver = chromedriver_autoinstaller.install()
options = webdriver.ChromeOptions()
prefs = {'profile.default_content_setting_values.automatic_downloads': 1}
options.add_experimental_option("prefs", prefs)
driver = webdriver.Chrome(options=options)
When I am running GitLab job, my pipeline is failing with below error
Below if the GitLab runner I can see used while running :
I also tried to used remote driver and headless mode- In headless mode most of tests are failing. In remote mode, it not instantiating driver. Remove driver code as below
elif self.browser == 'remote':
driver = webdriver.Remote(options=webdriver.ChromeOptions(), command_executor='http://selenium__standalone-chrome:4444/wd/hub')
I am not sure if its happening due to gitlab runner. Or Do I need to create my custom gitlab runner to run on specific machine. I am running selenium UI tests , so not sure runner which is used in my case don't have facility to run in GUI mode.
I found similar issue here- WebDriverException: Message: unknown error: Chrome failed to start: crashed error using ChromeDriver Chrome through Selenium Python on Amazon Linux
Tried below code but still same issue
options = Options()
options.binary_location = '/usr/bin/google-chrome'
driver = webdriver.Chrome(options=options,
executable_path='/usr/local/bin/chromedriver')
I am spinning image with -Docker executor with image joyzoursky/python-chromedriver:3.8
Upvotes: 2
Views: 2783
Reputation: 1
I have encountered the same problem as yours. My root issue, however, is because the chrome browser is not found in the /usr/bin/google-chrome. My solution is very much inspired by this post right here How to install chrome-webdriver on GitLab CI/CD. As of now, the stable version of chrome is 119.0.6045.105-1 on Ubuntu, make sure your driver's version is compatible with your driver.
Here is my .gitlab-ci.yml file:
before_script:
- apt-get update -qy
- apt-get install -y default-jre
- apt-get update
- apt-get install -y wget unzip curl
# Install or update Google Chrome
- CHROME_VERSION="119.0.6045.105-1"
# Install Google Chrome
- wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- dpkg -i google-chrome-stable_current_amd64.deb || apt --fix-broken install -y
- google-chrome-stable --version
Just my 2 cents! :D
Upvotes: 0
Reputation: 24962
Probably you are missing below options:
options = webdriver.ChromeOptions()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
For more inspirations go to: WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser
Upvotes: 1