WebDriver - wait for element using Python

WebDriver - wait for element using Python

In order to explicitly wait until an element is visible or clickable, the most direct and simple way is to use a WebDriverWait object in conjunction with the expected_conditions library. The following script shows this.

WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//a[strong[.='English']]")));

In order to do this you need to add the following lines to your imports:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions

See Working Example



Using Java

Leave a reply

Your email address will not be published. Required fields are marked*

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.