[UiPath] Webdriver protocol - headless browser support (with example)

Dear community members, I would like to show you an interesting approach to automation your web applications using a headless browser, or in other words, using a webdriver.

For this article, I prepared a demonstrational example: HeadlessChromeWebDriver.zip

Introduction

Headless browsers provide automated control of a web page in an environment similar to popular web browsers, but they are executed via a command-line interface or using network communication.
The WebDriver is a protocol used to automate browsers via REST API calls in a separate executable than the browser itself. This protocol is widely used for automated testing of web applications. Nonetheless, the WebDriver protocol is not strictly meant for headless browser automation, and can also be used to operate browsers visually.

So, this technology allows us to automate browser interaction without having any browser window open. All the automation runs in the background. This can be beneficial in some scenarios.

Awesome! Right? Well, let’s dig deeper to find out, that:

  • it can be used only in Open Browser activity scope.
  • activities such as Click, Type Into, e.g. must be configured to use the SimulateClick, SimulateType, or SimulateHover properties or the Send Window Messages property
  • Events Monitoring and Image Automation does not work in HeadLess mode.
  • more about limitations, read here: Known Issues and Limitations

Setup

1. Download webdriver

The Webdriver itself is an executable. Download Webdriver of the desired browser. In our example, we will work with Chrome.

Download the driver

Chrome - ChromeDriver - WebDriver for Chrome
Edge - Microsoft Edge WebDriver - Microsoft Edge Developer
Firefox - Releases · mozilla/geckodriver · GitHub

:exclamation: Important: the version of webdriver must match the version of the browser. To check it in Chrome go to Settings → About Chrome.
image

If your Chrome is up to date, then you should be fine with downloading the latest version of Chrome Webdriver
image
Unpack the archive and save ChromeDriver.exe to any location.
For example to C:\webdrivers\

2. Edit system variables

In Start, look for Edit environment variables for your account. Open it.
image

Select Path in User variables and click Edit…
image

In a new window, click New and enter the path to Webdriver location (in our case: C:\webdrivers)
image

3. Ready!

Restart your Robot Service and Studio and you should be good to go!

obrazek
If UiPath says it cannot find the Webdriver, I recommend checking all the steps once again and restarting your PC too.

How to use it?

You have to setup the Open Browser activity like this:

  • BrowserType: Chrome (or your desired browser)
  • CommunicationMethod: WebDriver (or Native for testing, and for visual webdriver use)
  • Hidden: True (False for visual webdriver use)

image

Example

I prepared an example demonstration workflow. Small project that use a simple website with a calculator.
This example includes two files:

  • Chrome.xaml - demo in Native, standard way
  • ChromeWebdriver.xaml - workflow adjusted for Webdriver use

:arrow_down_small: HeadlessChromeWebDriver.zip (88.3 KB) :arrow_down_small:

Summary

Pros:

  • operates fully in background
  • works with most major browsers
  • use same selectors as standard/native way

Cons:

  • need od extra setup on each robot machine
  • dependent on executable file that must be updated every time the browser updates

Thanks for this wonderful tutorial.

How to use this using “Use Application/Browser Activity”?

1 Like

@roman.hruska good article)
hehe, good old webdriver)
btw there is no need to monitor “webdirver” version “every day”, you can use old one as long as you want or until it is supported by “UiPath”.

1 Like

Hi!
You are welcome! Unfortunately, it does not seem to be possible now. I will update it once it is possible.

If you wish to use it in project that you set up as Modern Experience, you can still access the classic activities. Click funnel in Activities and tick Show Classic
image
You will be able to use open browser and other classic activities then. You will find them in category “Classic” :wink:
I hope this will help at least as a workaround.
Roman