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.
The latest release is from 2016. The best way for me was to download SeleniumBasic-188.8.131.52.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!