Install ChromeDriver and execute Robot Selenium tests in the Azure DevOps

Hi,
I am working on UI automation using the Robot Framework Selenium library. Currently, the code is in my local repository, but I would like to create a test pipeline(Azure Devops). However, I am facing the following challenges:

  1. How can I set up the ChromeDriver path when ‘executable_path’ is not supported by WebDriver?
  2. Do I need to install chrome while executing in headless mode

Would be great if you could help me with an example/best practices to be followed.

Hi KP,

This issue (Error downloading Chromedriver above 114 version · Issue #99 · MarketSquare/webdrivermanager · GitHub) has been an issue for many people here.

In looking for a workaround I think I’ve found one.

This is not tested yet

There is another python module for updating selenium drivers it’s called webdriver-manager not webdrivermanager, yeah the names are confusingly similar

webdriver-manager doesn’t have a commandline interface

however if we install it with pip install webdriver-manager

Then add the following line before any SeleniumLibrary keywords

${driverpath}=    Evaluate    webdriver_manager.chrome.ChromeDriverManager().install()    modules=webdriver_manager.chrome

I think this will work, not sure if we also need to update the path variable?

I’ll do some further tests later today, don’t have time right now, but hopefully this will help.

Dave.

1 Like

Hi KP,

FYI I got a chance to confirm this works:

	${driverpath}=    Evaluate    webdriver_manager.chrome.ChromeDriverManager().install()    modules=webdriver_manager.chrome
	Open Browser 	http://www.duck.com 	Chrome 	executable_path=${driverpath}

Dave.

1 Like

Thank you, Damies, for the quick response. It seems to have solved most of my problem. However, I get the following error when I execute scripts in the Azure DevOps pipeline.

SessionNotCreatedException: Message: session not created: Chrome failed to start: exited normally.
(session not created: DevToolsActivePort file doesn’t exist)
(The process started from chrome location /opt/google/chrome/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

Hi KP,

Does your test pipeline machine have a GUI?

For example If it’s a linux machine it needs the DISPLAY variable set in the OS, for that you will need a Display (X11 or Wayland), if it’s a VM or Docker container with no graphics card, then use XVFB.

Chrome (and most other browsers) won’t run without a GUI even when running headless.

Dave.

1 Like

I am executing it in an Azure VM, and I don’t think it has a UI. So, I assume I have to use XVFB. Please let me know if you have any references or snippets.

Hi KP,

Sorry I’m not familiar with Azure VM’s, from the website there appears to be Windows and Linux VM’s but it doesn’t say which Linux distro so I won’t be able to give you exact instructions.

As an overview if you’re using Linux you’ll need to:

  • install XVFB with your package manager (On Debian based distro’s use apt install xvfb
  • configure XVFB’s display number and run XVFB
  • Set the operating system variable $DISPLAY for the XVFB display number
  • run your robot test as the user where you configured the $DISPLAY variable

Windows VM’s already should have a GUI so if you’re using a Windows VM you have a different issue.

Hope that helps,

Dave.

1 Like

Thank you Dave. Really appreciate your help.

Below is how I solved it as you suggested

export DISPLAY=:99
Xvfb $DISPLAY -ac -screen 0 1024x768x16
xvfb-run --server-args=“-screen 0, 1024x768x16” robot Test

1 Like

I am not sure if I need to create a new thread for this query. I am getting below error when trying to execute same in GitLab.
++ inside Docker

I am using xvfb-run command to execute robotframework tests
Suite setup failed:
(session not created: DevToolsActivePort file doesn’t exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

Hi KP,

I’m not sure, I never used xvfb-run, I just ran xvfb as a background process before running robot and that’s what worked for me.

I had the pip installs between starting xvfb and running robot and that maybe gave xvfb enough time to startup and be ready for applications, and maybe using xvfb-run is not, but I’m just guessing here.

Dave.