Macro_Nerd99
Board Regular
- Joined
- Nov 13, 2021
- Messages
- 61
- Office Version
- 365
How do I interact with a Selenium.ChromeDriver that is already open, So I can accomplish something like the following
Right now, if I try code like this, I get a "object variable or With Block variable not set" Runtime error.
VBA Code:
Option Explicit
Dim ch As Selenium.ChromeDriver
Public Sub Open_Browser(website as string)
Set ch = New Selenium.ChromeDriver
ch.Start
ch.get website
End Sub
Public Sub Insert_Text_in_Box(textbox_name As String, text As String)
Dim Findby As Selenium.By
Set Findby = New Selenium.By
If ch.IsElementPresent(Findby.Name(textbox_name)) Then
ch.FindElementByName(textbox_name).Clear
ch.FindElementByName(textbox_name).SendKeys text
Else
ch.Quit
MsgBox "element not found"
Exit Sub
End If
End Sub
Public Sub test()
Open_Browser ("http://....com")
Insert_Text_in_Box "orderNumber", "123456"
End Sub
Right now, if I try code like this, I get a "object variable or With Block variable not set" Runtime error.