WebDriverWait or Dynamic wait Support
Hi,
I am trialing out this Selenium with Go. I would like to use WebDriverWait function to wait for an element to be visible / enabled.
For example, I can see this working with Java as mentioned here: https://www.seleniumhq.org/docs/04_webdriver_advanced.jsp
Is there a support for this with an example?
Regards, VP
If you go on the selenium documentation you will find that the signature of Wait is:
Wait(condition Condition) error.
Condition is defined as
type Condition func(wd WebDriver) (bool, error)
So we need to construct such a Condition function which returns true when the element is present or not.
In below you will find such an example.
func Enabled(by, elementName string) func(selenium.WebDriver) (bool, error) {
return func(wd selenium.WebDriver) (bool, error) {
el, err := wd.FindElement(by, elementName)
if err != nil {
return false, nil
}
enabled, err := el.IsEnabled()
if err != nil {
return false, nil
}
if !enabled {
return false, nil
}
return true, nil
}
}
It says selenium.Wait is not declared @AntonioL :(