Hi All,
I got a simple query, what can be the ideal sequence of events if I ignore the WebElement returned through WebDriverWait and ExpectedConditions?
MVCE:
System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
String xpath = "//*[@id=\"lst-ib\"]";
WebElement element = driver.findElement(By.xpath(xpath));
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.elementToBeClickable(element));
element.click();
element.sendKeys("Hello Selenium");
This block works. But my question is:
As per `WebElement element = driver.findElement(By.xpath(xpath));` the element have a reference to `driver.findElement(By.xpath(xpath));`. WebDriverWait keeps the driver engaged for 10 seconds. How do `element.click();` works if `findElement()` isn't invoked again?
PS: I do believe in the best practices to use the element returned from WebDriverWait. But this is just a query.
Thanks and Regards
Debanjan Bhattacharjee