2

Iam trying to run a selenium test in azure pipeline, the test works fine in my local machine with:

options = webdriver.ChromeOptions()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
chrome_exe= ChromeDriverManager()
driver = webdriver.Chrome(executable_path=chrome_exe.install(), options=options)

but when i run the same in the pipeline it fails with the following error.

E       selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
E         (unknown error: DevToolsActivePort file doesn't exist)
E         (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
/opt/hostedtoolcache/Python/3.6.11/x64/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py:242: WebDriverException
---------------------------- Captured stdout setup -----------------------------
 
---------------------------- Captured stderr setup -----------------------------
[WDM] - Current google-chrome version is 84.0.4147
[WDM] - Get LATEST driver version for 84.0.4147
[WDM] - There is no [linux64] chromedriver for browser 84.0.4147 in cache
[WDM] - Get LATEST driver version for 84.0.4147
[WDM] - Trying to download new driver from http://chromedriver.storage.googleapis.com/84.0.4147.30/chromedriver_linux64.zip
[WDM] - Driver has been saved in cache [/home/vsts/.wdm/drivers/chromedriver/linux64/84.0.4147.30]

manually i go to that path it says: No such object: chromedriver/84.0.4147.30 but if i query using link it gives the same version number

rahul knair
  • 103
  • 11

1 Answers1

0

chromedriver azuredops pipeline failure

According to the error message, it seems the Chrome browser is not installed at the default location within your system.

For the Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary.

If you are using a Chrome executable in a non-standard location you can try to override the Chrome binary location as follows:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.binary_location = "C:\\path\\to\\chrome.exe"    #chrome binary location specified here
options.add_argument("--start-maximized") #open Browser in maximized mode
options.add_argument("--no-sandbox") #bypass OS security model
options.add_argument("--disable-dev-shm-usage") #overcome limited resource problems
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=options, executable_path=r'C:\path\to\chromedriver.exe')
driver.get('http://google.com/')

You could check this thread for some details.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • Ok bit since, this is an .exe how do i set the path for linux binary for chrome and take that when it is running in a Linux pipeline and take this binary only if it is running in the local machine? – rahul knair Aug 17 '20 at 09:37