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-220.127.116.11.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.
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
Dim chrobj as Selenium.ChromeDriver Set chrobj = New Selenium.ChromeDriver
Then You can pass the website address.
You can also change the Chrome window property.
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!
19 thoughts on “Google Chrome automation with Selenium Basic”
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.
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!
Can You please tell me how to automate existing Edge browser using excel VBA.
Please guide through VBA coding
I will do the article about Edge for sure!
Or automating already running Chrome Browser please!!?
I don’t think it is possible using Selenium.
Chrome is getting updates regulary – does it means we have to update the Chromedriver manually, a swell?
Unfortunately yes, but You can turn off the updates to be sure that your tool will always work properly.
Argh :), I was expecting an automatic Chromedriver update
I promise I will dig into this one!
Can an Excel workbook using Selenium be shared between users, or would they all need to download Selenium?
Every user needs to have Selenium installed.
could you please write a sample code in vbscript but not VBA to automate chrome or edge for me
Have You tried anything?
VBScript is basically almost the same as VBA, just saved with .vbs extension. 🙂
I will think about it for sure!
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
Yes and it will be shown in next article 🙂
Is there a way to find an already open chrome window and a particular open url?
In general – yes, by using FindWindow function.
In case of Selenium Basic – I don’t think it is any possibility to do that.