Google Chrome automation with Selenium Basic

In my previous article I showed You how to scrap websites using good old buddy Internet Explorer. It is ok, but in case of more complex Java Script frontend sites our good old buddy might be not enough. In this post I will show You what You need to do to create web automation using Chrome with Selenium Basic.

What is Selenium Basic?

Selenium Basic is a Selenium based browser automation framework for VB.Net, VBA and VBScript. It makes it possible to automate web browsing using Excel and VBA code or using a simple VBS file executed by double-clicking on it. User’s actions can be recorded using the Firefox plugin named “Selenium IDE” and translated to VBA or VBS with the provided formatters.

You can find it here or view it on GitHub. Seleniumbasic maintained by florentbr.

The latest release is from 2016. The best way for me was to download SeleniumBasic-2.0.9.0.exe and install it on computer. Thanks to that solution the Selenium reference, wherever You choose the installation path, automatically appears in the VBE References.

.NET Framework 3.5

Also what You need to know , that this Selenium Basic solution will not work if You don’t have installed at least .NET Framework 3.5

Make sure that You have installed the framework on your pc by checking Registry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\ and there the version (v) folders. If there is a folder Full and Release file You can be sure that this version is installed.

In my case as You can see I got installed .NET Framework v4.0

You can verify the version of the framework by checking the Turn Windows features on or off in the Programs and Features of Control Panel/Programs.

Don’t be confused, this is screenshot from my other computer – that’s why the versions are different.

Chrome driver

So after installation and making sure that You have .NET Framework You need to do one more thing! You need to replace the Chrome driver in the place You’ve installed the Selenium Basic.

First of all, check the version of your Google Chrome. Click on the triple dot in the right top corner, go to Help and select About Google Chrome.

After that You’ll see the information about the Chrome’s version.

Based on that go to the Chrome driver website to the Downloads category and find the driver counterpart for your version of Chrome.

After downloading You need to unzip the driver and replace the content in the Selenium Basic installation path.

Finalazing that, You can go to the coding.

Finally, coding part

If You did everything what is needed above, You can start the coding part. So after all You can launch the Excel application and set the Selenium Type Library in the references as I showed You in the beginning of this article.

Then You need to declare the new ChromeDriver of Selenium library. You can do this in two ways:

Dim chrobj As New Selenium.ChromeDriver

or:

Dim chrobj as Selenium.ChromeDriver
Set chrobj = New Selenium.ChromeDriver

Then You can pass the website address.

chrobj.Get "https://simpleexcelvba.com

You can also change the Chrome window property.

chrobj.Window.Maximize

Code

Sub ChromeAutomation()

 Dim chrobj As New Selenium.ChromeDriver
 chrobj.Get "https://simpleexcelvba.com"
 chrobj.Window.Maximize

End Sub

All right! Now You know everything to start web scraping and do your own web automation in Google Chrome using Selenium Basic. Everything is on the silver platter here, start your web automation today!

Author: Tomasz Płociński

I'm very advanced in VBA, Excel, also easily linking VBA with other Office applications (e.g. PowerPoint) and external applications (e.g. SAP). I take part also in RPA processes (WebQuery, DataCache, IBM Access Client Solutions) where I can also use my SQL basic skillset. I'm trying now to widen my knowledge into TypeScript/JavaScript direction.

25 thoughts on “Google Chrome automation with Selenium Basic”

  1. Thanks, dear Tomek!
    what about the same with Firfeox?
    I’m getting mad, because all runs (IE, edge, phantomjs, chrome), but by no chance with Firefox. Must be the version.
    Any ideas?
    Cheers,
    Val

    1. Hi Val
      Haven’t tried yet with Firefox. Can’t tell You much about this case. Sorry
      But I will try that approach in the free time for sure!

      1. Can You please tell me how to automate existing Edge browser using excel VBA.
        Please guide through VBA coding

          1. Hi Sir,

            Or automating already running Chrome Browser please!!?

            Thank You

          2. Hello Jeremia
            I don’t think it is possible using Selenium.

  2. Chrome is getting updates regulary – does it means we have to update the Chromedriver manually, a swell?

    1. Unfortunately yes, but You can turn off the updates to be sure that your tool will always work properly.

  3. Can an Excel workbook using Selenium be shared between users, or would they all need to download Selenium?

  4. Hi Tomasz,

    could you please write a sample code in vbscript but not VBA to automate chrome or edge for me

    Thanks,
    Sunil

    1. Hello Sunil
      Have You tried anything?
      VBScript is basically almost the same as VBA, just saved with .vbs extension. 🙂
      I will think about it for sure!

  5. Hi, thank you very much.
    Do you know three other commands?
    1 – paste excel data in Chrome
    2 – click a button
    3 – copy results to excel

  6. Is there a way to find an already open chrome window and a particular open url?

    1. Hi Julian
      In general – yes, by using FindWindow function.
      In case of Selenium Basic – I don’t think it is any possibility to do that.

  7. I am receiving the follow error: “Run-Time error ‘-2146233078 (8013150a)’: The sourse was not found, but some or all event logs could not be searched. Inaccessible logs: Security, State.”

      1. I have the same error, on line Set chrobj = New selenium.EdgeDriver.
        I did everything as in the tutorial.

  8. Run-time error ‘-2146232576 (80131700)’: Automation error
    line code : chrobj.Start “chrome”

    pls give solution for it.

    1. Hello Mumba
      Do You have driver in line with Chrome version?
      Still need bigger picture than just this one line of your code to help You 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *