ag is a code-searching tool, similar to awk and grep and its mainly used to searching large trees of source code. it requires perl to run and portable with any platform.
Wednesday, May 13, 2015
Friday, May 8, 2015
Selenium and Webdriver waits
Here, I have listed all waits methods which is used in selenium web driver. It's helpful to eliminate the random failures from your test suites.
Implicit waits
Implicit waits
Selenium execution will wait for a specified time period to load the DOM elements.After that it will check the presence of web elements in the DOM, if not then throw errors.
Example: driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS)
Explicit waits:
Selenium execution will wait for a specified time period to load the locator and it will check the condition every 500ms.
Wait
wait = new WebDriverWait(driver, 30);
WebElement element= wait.until(visibilityOfElementLocated(By.id(“locator")));
Web driver waits
There is a default web driver waits to check the presence, visibility, clickable and invisible and it will check the condition every 500ms.
Wait
wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.invisibilityOfElementLocated(locator));
wait.until(ExpectedConditions.presenceOfElementLocated(locator));
wait.until(ExpectedConditions.elementToBeClickable(locator));
wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
Fluent wait:
If you want to check the presence of the web element in a specific time interval for maximum limit.
For Example: it waits until the element with id “100" is found. If the element is not found, retry every 5 seconds. But wait only up to a maximum of 60 seconds.
Wait wait = new FluentWait(driver)
.withTimeout(60, SECONDS)
.pollingEvery(5, SECONDS)
.ignoring(NoSuchElementException.class);
WebElement foo = wait.until(new Function() {
public WebElement apply(WebDriver driver) {
return driver.findElement(By.id("id100"));
}
Wait for Ajax calls in capybara.
This will helpful to wait until all ajax calls completion.
def wait_for_ajax
count = Capybara.default_wait_time * 10
actual_count = 0
count.times do
break if page.evaluate_script 'window._ajax_sent == window._ajax_completed'
actual_count += 1
sleep 0.1
end
fail 'wait_for_ajax timed out! Please check for javascript errors in the context of the test!' if actual_count>= count
end
Subscribe to:
Posts (Atom)
560 Free Online Courses
Top 200 universities launched 500 free online courses. Please find the list here .