Advertisement
YasserKhalil2019

Drop Down In Selenium VBA

May 3rd, 2021
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. Dim cd As Selenium.ChromeDriver
  2.  
  3. Sub Test()
  4. Dim BaseURL As String
  5. Dim DateOptions As List 'Selenium.WebElements
  6. Dim DateOption As SelectElement 'Selenium.WebElement
  7.  
  8. BaseURL = "https://finance.yahoo.com/quote/SPCE/options"
  9.  
  10. Set cd = New Selenium.ChromeDriver
  11.  
  12. cd.Start
  13. cd.Get BaseURL
  14.  
  15. 'cd.FindElementByCss("button").Click
  16. Set DateOption = cd.FindElementByCss("div > select[data-reactid='5']").AsSelect
  17. With DateOption
  18. Debug.Print .Options.Count
  19. Debug.Print .Options.First.Text
  20. Debug.Print .Options.Last.Text
  21. Debug.Print .Options(1).Text
  22. Set DateOptions = .Options.Text
  23. End With
  24. DateOptions.ToExcel Range("A1")
  25. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement