Thursday, July 15, 2010

The fast way to locate page elements on PageFactory

From PageFactory.java source code, it has a demo that without @FindBy annotation, it will find page element using Xpath by default, which is a Clean and Smart way, however not a fast way:

public class Page {
private WebElement submit;
}

there will be an element that can be located using the xpath expression
"//*[@id='submit']" or "//*[@name='submit']"


So from performance perspective, I will be glad to use @FindBy annotation way:

public class Page {
@FindBy(How.ID_OR_NAME, using="submit")
private WebElement loginbutton;
}

No comments:

Post a Comment