How do I interact with a Selenium.ChromeDriver that is already open.

Macro_Nerd99

Board Regular
Joined
Nov 13, 2021
Messages
61
Office Version
  1. 365
How do I interact with a Selenium.ChromeDriver that is already open, So I can accomplish something like the following

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.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,216,221
Messages
6,129,585
Members
449,520
Latest member
TBFrieds

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top