Plan9
Plan9

Reputation: 11

Problem with Selenium FindElements in Excel

This is probably a nooby question butI have used the other Selenium findElementBy and findElementsBy methods with no problems but using the findElements method causes a compile error ... Variable not defined with By highlighted in the line driver.FindElements(By.id(locator)). Any examples I have found look similar to my syntax. I would like to use this method as it returns an empty list if it fails to find.

Dim driver As New ChromeDriver
Dim url As String
Dim ele As WebElement
Dim eles As WebElements
Dim locator As String

locator = "myId"
url = "https://myUrl"
driver.Get url
driver.Window.Maximize
Application.Wait (Now + TimeValue("0:00:05"))

eles = driver.FindElements(By.id(locator))
Application.Wait (Now + TimeValue("0:00:05"))
driver.Quit

Upvotes: 1

Views: 58

Answers (1)

Atanas Atanasov
Atanas Atanasov

Reputation: 471

I'm not sure of the syntax, but maybe try to add this at the beginning:

Imports OpenQA.Selenium.By

Upvotes: 0

Related Questions