Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,604
- Office Version
- 365
- 2016
- Platform
- Windows
Does anyone here have experience with manipulating browser (Firefox) input via Excel VBA. Is it even possible?
I have been working on some test code that uses Selenium and Geckodriver to try and accomplish this. Looking to access a webpage, populate it's search field, and execuate the search.
I've accessed the Firefox prerequisistes. I have a valid version (v133) of Firefox, v0.35 of geckodriver, and I have installed Selenium 4.27.1 via Python. I originally installed the Selenium Basic, but realized it wasn't supported by geckodriver. I installed Python hoping that the Python based Selenium (?) would be what I needed. Not sure though now. The only difference I found in configuring everything, was there are no libraries to add to Excel references unlike the Basic vesion.
here is my code I'm experimenting with:
The line in red stops the code with an error: "User-defined type not defined
I had gotten closer with this code when I was using Selenium basic. It would open up a Firefox window, but would timeout on the line in purple. Error: "TimeoutErrorFirefox failed to open the listening port 127.0.0.1:12825 with 15s" (I didn't get the error associated with the red line).
Grateful to hear from others with experience with this concept of VBA based webpage manipulation in whatever method (if any) that works. I am prepared for this method not to work, but I hope there are other options if not.
I did cross post (more detailed) at the Selenium user support page, but it has been several days stuck in moderator approval. It hasn't been posted yet.
I have been working on some test code that uses Selenium and Geckodriver to try and accomplish this. Looking to access a webpage, populate it's search field, and execuate the search.
I've accessed the Firefox prerequisistes. I have a valid version (v133) of Firefox, v0.35 of geckodriver, and I have installed Selenium 4.27.1 via Python. I originally installed the Selenium Basic, but realized it wasn't supported by geckodriver. I installed Python hoping that the Python based Selenium (?) would be what I needed. Not sure though now. The only difference I found in configuring everything, was there are no libraries to add to Excel references unlike the Basic vesion.
here is my code I'm experimenting with:
Rich (BB code):
Sub OpenWebsiteInFirefox()
' Declare Selenium variables
Dim driver As New Selenium.WebDriver
Dim searchBox As Object
Dim geckopath As String
Dim searchTerm As String
geckopath = "C:\Operations\geckodriver.exe"
searchTerm = "Historic Chess Masters"
' Start Firefox browser
driver.Start "firefox", geckopath
' Navigate to the website (for example, Google)
driver.Get "https://www.drinkwillibald.com/"
' Wait for the page to load (adjust the sleep time as needed)
driver.Wait 2000
' Find the search box using its name or ID
Set searchBox = driver.FindElementByName("q")
' Type in the search box
searchBox.SendKeys "Excel VBA automation"
' Execute the search by pressing Enter
searchBox.SendKeys Keys.Enter
' Wait for results to load (optional)
driver.Wait 2000
End Sub
The line in red stops the code with an error: "User-defined type not defined
I had gotten closer with this code when I was using Selenium basic. It would open up a Firefox window, but would timeout on the line in purple. Error: "TimeoutErrorFirefox failed to open the listening port 127.0.0.1:12825 with 15s" (I didn't get the error associated with the red line).
Grateful to hear from others with experience with this concept of VBA based webpage manipulation in whatever method (if any) that works. I am prepared for this method not to work, but I hope there are other options if not.
I did cross post (more detailed) at the Selenium user support page, but it has been several days stuck in moderator approval. It hasn't been posted yet.