Thread.Sleep or Wait or FluentWait

Instead of sleep

public void clickOntaskType() {

getDriver().findElement(By.id("tasktypelink")).click();

sleep(500);

}

Prefer this fluentWait

public void clickOntaskType() {

getDriver().findElement(By.id("tasktypelink")).click();

SeleniumUtil.fluentWait(By.name("handle"), getDriver());

}

It’s more robust, deterministic, in case of element not found… the exception will be clearer.

Another alternative is

(new WebDriverWait(driver, 30)).until(new ExpectedCondition() {

public Boolean apply(WebDriver d) {

return d.getTitle().toLowerCase().startsWith("Awesome Tester");

Locating UI Elements–which to use

To locate an element we can use

the element’s ID

the element’s name attribute

an XPath statement

by a links text

document object model (DOM)

In practice, you will discover

id and name are often the easiest and sure way.

xpath are often brittle. for example you have 3 tables displayed but sometimes there are no data and the table isn’t rendered, your xpath locating the second table will not always return the intented one.

css are the way to go in conjunction of id and name !

locating links in an internationalized application is sometimes hard… try to use partial href.

Coded UI with Action Based Test Automation

A good video which gives a great overview of using Coded UI along with Action based test automation.

www.CodeNirvana.in

Powered by Blogger.

Translate

Total Pageviews

Copyright © T R I A G E D T E S T E R