Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. @FindBy(how=How.NAME, using="username")
  2. private WebElement user_name;
  3.  
  4. The @FindBy annotation supports a handful of other strategies that
  5.  
  6. make things a bit easier:
  7.  
  8. id, name, className, css, tagName, linkText, partialLinkText, xpath
  9.  
  10. @FindBy(id="username")
  11. private WebElement user_name;
  12. @FindBy(name="passsword")
  13. private WebElement user_password;
  14. @FindBy(className="class23")
  15. private WebElement label;
  16.  
  17. @FindBy(css=”#content”)
  18. private WebElement text;
  19.  
  20. Once initialized, these WebElement variables can then be used to
  21. interact with the corresponding elements on the page. The following code
  22. will, for example:
  23. user_name.sendkeys(username
  24. send the given sequence of keystrokes to the username field on the
  25. page, and it is equivalent to:
  26.  
  27. driver.findElement(By.name(“user_name”)).sendKeys(username);
  28.  
  29. Suppose if we need to find the list of elements on the page then we can
  30.  
  31. use
  32.  
  33.  
  34. @FindBys
  35.  
  36. @FindBys(@FindBy(xpath=”div[class='btn_llogin']”)))
  37. private List btn_lists;
  38.  
  39. The above code will find all the div elements with class "btn_llogin"
  40.  
  41. Additionally, you can use @FindAll with multiple @FindBy annotations to
  42. look for elements that match any of the given locators:
  43.  
  44. @FindAll({@FindBy(how=How.ID, using=”username”),
  45. @FindBy(className=”username-field”)})
  46. private WebElement user_name;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement