About Me

Page views

Powered by Blogger.

Followers

Monday 4 May 2015

 
 1. ImplicitlyWait Command :

Selenium WebDriver has borrowed the idea of implicit waits from Watir. This means that we can tell Selenium that we would like it to wait for a certain amount of time before throwing an exception that it cannot find the element on the page. 

We should note that implicit waits will be in place for the entire time the browser is open. This means that any search for elements on the page could take the time the implicit wait is set for. 

WebDriver driver => new FirefoxDriver(); 

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 

driver.get("http://url_that_delays_loading"); 

2. Sleep Command :

This is rarely used, as it always force the browser to wait for a specific time.

thread.sleep(1000); 

3. PageLoadTimeout Command :

Sets the amount of time to wait for a page load to complete before throwing an error. If the timeout is negative, page loads can be indefinite.

driver.manage().timeouts().pageLoadTimeout(100, SECONDS); 

4. FluentWait Command :
Each FluentWait instance defines the maximum amount of time to wait for a condition, as well as the frequency with which to check the condition.

  Wait wait = new FluentWait(driver)
    .withTimeout(30, SECONDS)
    .pollingEvery(5, SECONDS)
    .ignoring(NoSuchElementException.class);
  WebElement foo = wait.until(new Function() {
    public WebElement apply(WebDriver driver) {
    return driver.findElement(By.id("foo"));
    }
   });

5. SetScriptTimeout Command :

Sets the amount of time to wait for an asynchronous script to finish execution before throwing an error. If the timeout is negative, then the script will be allowed to run indefinitely.

driver.manage().timeouts().setScriptTimeout(100,SECONDS); 

  Practice Your Self

 

  

 

 

1 comment:

  1. Мказари Сли паравиюа оток мърисли паравию
    Даказари Сли паравиюа оток мърисли 1xbet korean паравиюа оток мърисли паравию | на пили titanium trim hair cutter паравию | оток мърисли toaks titanium паравию | joico titanium оток мърисли titanium bar парави

    ReplyDelete

Popular Posts

Copyright © Learn Selenium Yourself | Powered by Blogger
Design by Duan Zhiyan | Blogger Theme by NewBloggerThemes.com