Integrating UiPath with Webdriver

February 21, 2018 | Robotics

Integrating UIPath

The time may come where you need some functionalities that UiPath does not have yet or requires a high level of effort to implement – like scrolling to the end of a growing webpage.

We will use scraping Twitter followers as a working example.

First, scrolling to the end of a page after attaching to a web browser window is solved simply by sending the <End> hotkey to a browser window. But how many times you must send the <End> key, and how long after then with the key be ignored before the next chunk of data is loaded?

Since 2017 W3C published new recommendations for remote control interfaces for browsers: WebDriver W3C Candidate Recommendation. Google integrated a remote-control mechanism in their Chrome browser: ChromeDriver – WebDriver for Chrome. And last piece of the puzzle is Selenium’s WebDriver for Chrome that can also be downloaded from NuGet website. Having all those tools is now extremely easy to implement a sample UiPath custom activity that make use of web driver capabilities embedded into Chrome web browser.

Before starting coding we need to download ChromeDriver and extract it in a path that will later be used by our custom activity / robot.

After creating new project in Visual Studio we have to install the  Selenium.WebDriver.ChromeDriver NuGet (e.g. type in Package Manager Console Install-Package Selenium.WebDriver.ChromeDriver -Version 2.35.0) and then we can use the web driver to control our browser.

Open browser:

IWebDriver driver = new ChromeDriver(ExeAppPath);



Type the UserName (variable _username):

IWebElement email = driver.FindElement(By.ClassName(“js-username-field”));

Actions builder = new Actions(driver);

Actions seriesOfActions = builder.MoveToElement(email).Click().SendKeys(email, _username);


Type the Password (variable _password):

IWebElement password = driver.FindElement(By.ClassName(“js-password-field”));

builder = new Actions(driver);

seriesOfActions = builder.MoveToElement(password).Click().SendKeys(password, _password);


Press <Login> Button:

IWebElement buttonLogIn = driver.FindElement(By.Id(“page-outer”)).FindElement(By.ClassName(“submit”));


Navigate to <Followers> page:


Please note that the ExeAppPath variable has already been initialized with path where ChromeDriver was extracted.

The solution that we selected for this example for scrolling the page to the end is to run JavaScript code remotely in the controlled browser instance ( The delay in the function can be extracted as parameter for the custom activity for now.

private void ScrollToBottom(IWebDriver driver, Int32 scrolldelay)


long scrollHeight = 0;



       IJavaScriptExecutor js = (IJavaScriptExecutor)driver;

       var newScrollHeight = (long)js.ExecuteScript(“window.scrollTo(0, document.body.scrollHeight); return document.body.scrollHeight;”);

       if (newScrollHeight == scrollHeight)






              scrollHeight = newScrollHeight;



      } while (true);


We call <ScrollToBottom> function after navigating to Followers page and then extract all followers also using web driver functionalities. At the end we close the browser and release the driver:

ScrollToBottom(driver, _scrolldelay);

IList<IWebElement> profiles = driver.FindElements(By.ClassName(“ProfileCard-screennameLink”));

DataRow dr;

foreach (IWebElement profile in profiles)


dr = dt.NewRow();

       dr[“account”] = profile.Text;





The DataTable produced in this example can be used as <Out> parameter for the custom activity so we can use the followers list in our robot. So the activity will receive UserName, Password and ScrollDelay as input arguments and will produce a DataTable containing all followers for that Twitter account.

Defensive programming: Feel free to put together all these pieces in a custom activity while not forgetting to gracefully end the activity execution in case of an error; Going further you can have an output parameter that robot can check as soon as activity terminates to determine if an error happened.

Related Articles

What role should a Managing Partner play in driving tech & innovation?

March 24, 2020 | Digital Transformation | Legal | Robotics

Introduction Almost every leadership book ever written talks about the importance of delegation and surrounding yourself with brilliant people who are each experts in their own discipline. For a long time, this was the prevailing attitude from Managing Partners towards technology. But when does technology cease to be peripheral and become a core competence? When […]

7 ways in which the best law firms are attracting and retaining top talent

June 17, 2019 | Digital Transformation | Legal | Robotics

The best law firms understand that they have to treat their employees as customers, and that means really understanding what matters to them. This article will explore some of those key drivers and how the best firms are turning them to their advantage. 1 – Smart lawyers know that the future rests with the firms […]

The Six Factors Changing Local Government Forever

May 24, 2019 | Digital Transformation | Local Government | Robotics

Many Local Governments stand on the brink of bankruptcy after years of underfunding and budget cuts. Employees are overworked and underpaid, whilst Chief Executives are forced to make difficult decisions which affect the lives of their constituents. T-Impact have identified six key factors that are changing Local Government and senior staff need to adapt to […]