Reputation: 1
I am trying to open the edge browser with my VBA code, and I can't seem to make it work, the error I get is the one in the title: "TimeoutError The driver failed to open the listening port 127.0.0.1:54901 whithin 10s"
The version I have for edge according to the browser is 126.0.2592.87 (64 bits) The driver version I installed is just the same (i picked the one that says x64, because that's the windows version I have) and I extracted the data from the zip inside the following path: "C:\Users\username\AppData\Local\SeleniumBasic"
Selenium is also inside that.
I don't know what else to do.
Here's the code for reference:
Sub buscarPreco()
Dim browser As New WebDriver
browser.Start "edge", "C:\Users\username\AppData\Local\SeleniumBasic\edgedriver.exe"
browser.Get "/"
browser.Wait 5000
Cells(2, 2).Value = browser.FindElementById("price_inside_buybox").Attribute("innerText")
Navegador.Quit
End Sub
Upvotes: 0
Views: 398
Reputation: 1
Go to here:
https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/?cs=2626455528&form=MA13LH
Download the driver that matches your version of Edge. Extract and rename it from 'msedgedriver.exe' to 'edgedriver.exe'
Move the edgedriver.exe file to the following folder: C:\Users\YourName\AppData\Local\SeleniumBasic
Make sure you have a reference to Selenium in EXCEL or whatever program your using VBA with:
VBA Editor/Tools/References, look for and check: 'Selenium Type Library'
To start Selenium:
Add variable and assign at the very top of your VBA code below 'Option Explicit':
Option Explicit
Dim bot As New Selenium.EdgeDriver
In your VBA code add:
Sub buscarPreco()
bot.Start
bot.Get "your URL Here"
bot.Wait 5000
Dim myElementValue as String
myElementValue = bot.FindElementById("price_inside_buybox").Attribute("innerText")
If isnull(myElementValue) or myElementValue = "" then
msgbox "No Element Value Found", vbInformation, "For Information..."
else
Cells(2, 2).Value = myElementValue
End if
bot.Quit
End Sub
Upvotes: 0