3

I am trying to manipulate Chrome from the Excel VBE using the Selenium add-in.

  • I have included Selenium Type Library in my references.
  • I am running Chrome v67.
  • I have replaced the Chromedriver.exe file in the Selenium Basic directory with the version compatible with Chrome v67 (i.e. Chromedriver version 38).

My VBA code:

Public Sub seleniumtutorial()
Dim bot As New WebDriver
'bot.AddArgument "--headless"
'bot.AddArgument "--disable-extensions"
bot.Start "chrome", "http://google.com"
bot.Get "/"
bot.TakeScreenshot.SaveAs (ActiveWorkbook.Path + "/screenshot.jpg")
bot.Quit
End Sub

I am getting the following error message:

enter image description here

If I include this line of code there is no error message but then I cannot see the Chrome window:

bot.AddArgument "--headless"

If I include this line of code, as was suggested on SO answers to a similar question, it doesn't solve the issue.

bot.AddArgument "--disable-extensions"
Community
  • 1
  • 1
Noobster
  • 1,024
  • 1
  • 13
  • 28

1 Answers1

1

From a VBA perspective you are using the wrong driver class to automate Chrome. You confirmed the location of ChromeDriver but it is completely ignored in your code.

Replace WebDriver with ChromeDriver in this line: Dim bot As New WebDriver

Or use: Dim bot As New Selenium.ChromeDriver

That's problem #1. Problem #2 is the error message you are getting. You should be getting a run-time error when you use WebDriver not a policy warning.

Not enough information provided to solve problem #2 and it may not have anything to do with VBA. Given the error message, you may want to have a chat with your admin.

ProfoundlyOblivious
  • 1,455
  • 1
  • 6
  • 12