Using Google Chrome in Selenium VBA (Installation Steps)
I am having problems even setting up Selenium for VBA. I have been reading online on what to do, download the selenium (https://github.com/florentbr/SeleniumBasic/releases/tag/v2.0.9.0) add extension and etc. However, I am still struggling to get it to work.
Even writing a simple code like the following which I have found online:
Public Sub Demo()
Dim d As WebDriver
Set d = New ChromeDriver
Const URL = "https://www.google.com/"
With d
.Start "Chrome"
.get URL
.FindElementById("lst-ib").SendKeys "Selenium basic GitHub"
.FindElementsByTag("form")(1).FindElementByCss("input[value='Google Search']").Click
'.Quit
End With
End Sub
Gives me an Automation error.
I would like to use google chrome in the same way as internet explorer. I would appreciate any help with setting up selenium , and I know my question can be seen as silly.
Solution 1:
First of all, go to control panel and uninstall previous installation of selenium and then follow the steps
1- Download the latest version of chrome and make sure of the version of Chrome from Help >> About Google Chrome. You would see something like that Version 75.0.3770.142 (Official Build) (32-bit)
2- Download the latest version from the LINK
3- Download the chromedriver from the follwoing LINK
Make sure of the version that suits your chrome version
As for the Google Chrome version I posted the most suitable version of chromedriver is ChromeDriver 75.0.3770.140
Now setup SeleniumBasic >> After setup unzip the chromedriver file
chromedriver_win32.zip
and copy the chromedriver.exe to the path of selenium Here's two possibilties: First >>C:\Program Files\SeleniumBasic
Second >>C:\Users\%username%\AppData\Local\SeleniumBasic
Copy the chromedriver.exe to the SeleniumBasic pathOpen new blank excel file >> Press Alt + F11 (Visual Basic Editor) >> Tools >> References >> Selenium Type Library
Insert new module and paste the following code to test
Sub Test()
Dim bot As New WebDriver
bot.Start "chrome", "https://www.google.com"
bot.Get "/"
Stop
End Sub
Solution 2:
I degraded chrome.exe to one version lower downloads (off the selenium chrome webdriver site) in Users/?/AppData/Local/SeleniumBasic directory and it worked. ..running windows 10.