Friday, August 5, 2016

HomePage

 package com.mridul.framework.selenium.pages;  
 import com.mridul.framework.selenium.modals.ReportAnIssueModal;  
 import com.mridul.framework.selenium.modals.WebAuthorHelpModal;  
 import org.openqa.selenium.By;  
 import org.openqa.selenium.WebDriver;  
 import org.openqa.selenium.WebElement;  
 import org.openqa.selenium.interactions.Actions;  
 import org.openqa.selenium.support.FindBy;  
 import java.util.Arrays;  
 import java.util.List;  
 /**  
  * Created by Mridul on 3/11/2016.  
  */  
 public final class HomePage extends AbstractPage {  
   //anchors  
   @FindBy(css = "a[href='home.do'] > img")  
   private WebElement img_DashLogo_Anchor;  
   //page elements  
   @FindBy(css = "a[label='Logout']")  
   private WebElement lnk_Logout;  
   @FindBy(id = "menu_search")  
   private WebElement fld_MenuSearch;  
   @FindBy(xpath = "//*[@id='cssmenu']/ul/li[4]/a/span")  
   private WebElement lbl_ReportAnIssue;  
   @FindBy(xpath = "//*[@id='cssmenu']/ul/li[5]/a/span")  
   private WebElement lbl_OrderStuff;  
   //@FindBy(xpath="(//li[contains(@class,'sc_menu_item')]/a[contains(text(),'WebAuthor')])[2]")  
   @FindBy(xpath = "//*a[@data-target='#myModal' and contains(text(),'WebAuthor')][1]")  
   private WebElement lbl_WebAuthorHelp;  
   public HomePage(WebDriver driver) {  
     super(driver);  
   }  
   @Override  
   protected List<WebElement> registerAnchors() {  
     return Arrays.asList(img_DashLogo_Anchor);  
   }  
   @Override  
   public HomePage and() {  
     return this;  
   }  
   @Override  
   public HomePage then() {  
     return this;  
   }  
   public ReportAnIssueModal clickOnReportAnIssue() {  
     super.clickOnWebElement(lbl_ReportAnIssue);  
     return new ReportAnIssueModal(driver, this);  
   }  
   ////TODO-Hack, refactor later  
   public WebAuthorHelpModal clickOnWebAuthorHelp() {  
     Actions actions= new Actions(driver);  
     actions.moveToElement(lbl_OrderStuff).build().perform();  
     actions.moveByOffset(lbl_OrderStuff.getSize().getWidth(),0).click().build().perform();  
     this.sleep(2);  
     driver.findElement(By.partialLinkText("WebAuthor")).click();  
     return new WebAuthorHelpModal(driver, this);  
   }  
 }  

No comments:

Post a Comment