Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim drv As New Selenium.ChromeDriver
- Type selUT
- text As String
- xPath As String
- ele As WebElement
- eleEach As WebElements
- End Type
- Sub Test()
- Dim k As selUT
- drv.Get "https://www.google.com/"
- k.xPath = "//*[@id='tsf']/div[2]/div[3]/center/input[2]"
- If GetElement(k) Then
- MsgBox "Got Element"
- Else
- MsgBox "No Element"
- End If
- End Sub
- Function GetElement(k As selUT) As Boolean
- On Error GoTo Handler
- k.text = ""
- Set k.ele = drv.FindElementByXPath(k.xPath)
- k.text = k.ele.text
- GetElement = True
- Exit Function
- Handler:
- Err.Clear
- GetElement = False
- End Function
- Function GetElementEach(k As selUT) As Boolean
- On Error GoTo Handler
- k.text = ""
- Set k.ele = k.eleEach.FindElementByXPath(k.xPath)
- k.text = k.ele.text
- GetElementEach = True
- Exit Function
- Handler:
- Err.Clear
- GetElementEach = False
- End Function
- Function GetElementClick(k As selUT) As Boolean
- On Error GoTo Handler
- k.text = ""
- Set k.ele = drv.FindElementByXPath(k.xPath)
- k.ele.Click
- drv.Wait (1000)
- GetElementClick = True
- Exit Function
- Handler:
- Err.Clear
- GetElementClick = False
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement