Advertisement
Vb6solutions

Vb6 Selenium Error Code

Nov 20th, 2023
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. Dim drv As New Selenium.ChromeDriver
  2.  
  3. Type selUT
  4. text As String
  5. xPath As String
  6. ele As WebElement
  7. eleEach As WebElements
  8. End Type
  9.  
  10.  
  11. Sub Test()
  12. Dim k As selUT
  13.  
  14. drv.Get "https://www.google.com/"
  15. k.xPath = "//*[@id='tsf']/div[2]/div[3]/center/input[2]"
  16. If GetElement(k) Then
  17. MsgBox "Got Element"
  18. Else
  19. MsgBox "No Element"
  20. End If
  21. End Sub
  22.  
  23. Function GetElement(k As selUT) As Boolean
  24. On Error GoTo Handler
  25.  
  26. k.text = ""
  27. Set k.ele = drv.FindElementByXPath(k.xPath)
  28. k.text = k.ele.text
  29. GetElement = True
  30. Exit Function
  31. Handler:
  32. Err.Clear
  33. GetElement = False
  34. End Function
  35.  
  36. Function GetElementEach(k As selUT) As Boolean
  37. On Error GoTo Handler
  38.  
  39. k.text = ""
  40. Set k.ele = k.eleEach.FindElementByXPath(k.xPath)
  41. k.text = k.ele.text
  42. GetElementEach = True
  43. Exit Function
  44. Handler:
  45. Err.Clear
  46. GetElementEach = False
  47. End Function
  48.  
  49. Function GetElementClick(k As selUT) As Boolean
  50. On Error GoTo Handler
  51.  
  52. k.text = ""
  53. Set k.ele = drv.FindElementByXPath(k.xPath)
  54. k.ele.Click
  55. drv.Wait (1000)
  56. GetElementClick = True
  57. Exit Function
  58. Handler:
  59. Err.Clear
  60. GetElementClick = False
  61. End Function
  62.  
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement