Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @FindBy(how=How.NAME, using="username")
- private WebElement user_name;
- The @FindBy annotation supports a handful of other strategies that
- make things a bit easier:
- id, name, className, css, tagName, linkText, partialLinkText, xpath
- @FindBy(id="username")
- private WebElement user_name;
- @FindBy(name="passsword")
- private WebElement user_password;
- @FindBy(className="class23")
- private WebElement label;
- @FindBy(css=”#content”)
- private WebElement text;
- Once initialized, these WebElement variables can then be used to
- interact with the corresponding elements on the page. The following code
- will, for example:
- user_name.sendkeys(username
- send the given sequence of keystrokes to the username field on the
- page, and it is equivalent to:
- driver.findElement(By.name(“user_name”)).sendKeys(username);
- Suppose if we need to find the list of elements on the page then we can
- use
- @FindBys
- @FindBys(@FindBy(xpath=”div[class='btn_llogin']”)))
- private List btn_lists;
- The above code will find all the div elements with class "btn_llogin"
- Additionally, you can use @FindAll with multiple @FindBy annotations to
- look for elements that match any of the given locators:
- @FindAll({@FindBy(how=How.ID, using=”username”),
- @FindBy(className=”username-field”)})
- private WebElement user_name;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement