Implementation of Wait in Selenium
Implementation of Wait in
Selenium
1à
Thread.sleep() : This is the way by which we can hold the
execution of script for the predefined time
è
It
is forcefully wait for the given time
2à
Implicitely Wait
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://somedomain/url_that_delays_loading");
WebElement myDynamicElement = driver.findElement(By.id("myDynamicElement"));
The ImplicitWait will tell the webdriver to wait certain duration when trying to find the element, this will be useful when certain elements on the webpage will not be available immediately and needs some time to load.
This will work only with find element commands
3à
pageLoadTimeout()
By
this we can wait for a certain period of time to wait for a page to load.
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
4à
Wait for Element Present: By this we
can wait until a element present or application state to be changes
WebDriverWait wait = new WebDriverWait(firef, 10);
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@id=':gp']/div/div")));
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment