Advertisement
DSTRN

HomePage

Jan 17th, 2022
724
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.24 KB | None | 0 0
  1. import org.openqa.selenium.WebDriver;
  2. import org.openqa.selenium.WebElement;
  3. import org.openqa.selenium.support.FindBy;
  4.  
  5. public class HomePage {
  6.  
  7.     // Add Driver
  8.     private WebDriver driver;
  9.  
  10.     // Find elements that are used on that page
  11.  
  12.     @FindBy(css = "a[title=\"Contact Us\"]")
  13.     private WebElement contactUsLink;
  14.  
  15.     @FindBy(css = "a[class='login']")
  16.     private WebElement singInLink;
  17.  
  18.     @FindBy(id = "search_query_top")
  19.     private WebElement searchInput;
  20.  
  21.     @FindBy(name = "submit_search")
  22.     private WebElement submitSearchButton;
  23.  
  24.     // Create constructor for driver
  25.  
  26.     public HomePage(WebDriver driver) {
  27.         this.driver = driver;
  28.     }
  29.  
  30.     // Create methods for found elements
  31.  
  32.     public void contactUsLinkClick() {
  33.         Utilities.visibilityWait(driver, this.contactUsLink, 10).click();
  34.     }
  35.  
  36.     public void singInLinkClick() {
  37.         Utilities.visibilityWait(driver, this.singInLink, 10).click();
  38.     }
  39.  
  40.     public WebElement getSearchInput() {
  41.         return Utilities.visibilityWait(driver, this.searchInput, 10);
  42.     }
  43.  
  44.     public void setSearchInput(String value) {
  45.         WebElement el = getSearchInput();
  46.         el.clear();
  47.         el.sendKeys(value);
  48.     }
  49.  
  50.     public void submitSearchBtnClick() {
  51.         Utilities.clickableWait(driver, this.submitSearchButton, 10).click();
  52.     }
  53.  
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement