1
votes
driver= new InternetExplorerDriver(cap);
driver.get("http://Myurl.com"); 
WebDriverWait wait= new WebDriverWait(driver,10);   

Case 1:wait.until(ExpectedConditions.elementToBeClickable(By.id("Tesr"))); For Above Code driver is waiting for the approx 10 sec before throwing Exception But if use the below code passing WebElement to function" elementToBeClickable" it throw the exception after approx 500 ms

Case 2: wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.id("Tesr"))));

Please Anyone tell me why for case 2 driver is not waiting till the timeout value.

1
Can I know which exception do you find? - Sagar007

1 Answers

1
votes

When you use driver.findElement inside the explicit wait function, driver.findElement takes precedence in execution. Which simply means, WebDriver tries to find the element and supply the found element to the ExpectedCondiions.elementToBeClickable method. So when trying to find the element, the implicit wait(Global wait) is only taken into consideration and since the implicit wait in your case is 500ms and the element is not found NoSuchElementException is thrown.

No that if the exception was throws from the implicit wait you would have got TimeOutException. Instead you would have got NoSuchElementException which is from the driver.findElement method.