Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pageObjects.Utils;
- import com.sforce.trailhead.tcdev.pages.AbstractPage;
- import com.sforce.trailhead.tcdev.util.WebDriverUtils;
- import org.apache.commons.lang3.ObjectUtils;
- import org.openqa.selenium.support.ui.WebDriverWait;
- import org.openqa.selenium.support.ui.Select;
- import java.time.Duration;
- import java.util.ArrayList;
- import java.util.List;
- import com.sforce.trailhead.tcdev.pages.AbstractPage;
- import com.sforce.trailhead.tcdev.util.WebDriverUtils;
- import org.openqa.selenium.By;
- import org.openqa.selenium.Keys;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import com.sforce.trailhead.tcdev.pages.AbstractPage;
- import org.openqa.selenium.By;
- import org.openqa.selenium.JavascriptExecutor;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.support.ui.ExpectedConditions;
- import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIConversion;
- import org.openqa.selenium.*;
- import org.openqa.selenium.support.ui.ExpectedConditions;
- import org.openqa.selenium.support.ui.FluentWait;
- import pageObjects.Common.LeftPanel;
- /**
- * Page Object for common elements in Superbadges flows
- */
- public class Common extends AbstractPage {
- public Common(WebDriver driver) {
- super(driver);
- }
- WebDriverWait wait = new WebDriverWait(driver, 30);
- public static final Duration SHORT_TIMEOUT = Duration.ofSeconds(3);
- public static final Duration MID_TIMEOUT = Duration.ofSeconds(10);
- public static final Duration LONG_TIMEOUT = Duration.ofSeconds(30);
- private String SEARCH_TEXT = "";
- // ---------------------------------------------------------------
- // Strings
- // ---------------------------------------------------------------
- // ---------------------------------------------------------------
- // Locators
- // ---------------------------------------------------------------
- By IFRAME = By.cssSelector("iframe");
- // BUTTON "NEXT" 1: input.btn
- By BUTTON_NEXT01 = By.cssSelector("div.pbWizardFooter div input.btn");
- // BUTTON "NEXT" 2: div input:nth-child(2)
- By BUTTON_NEXT02 = By.cssSelector("div.pbWizardFooter input:nth-child(2)");
- // BUTTON "NEW" in Fields and Relationships within an Object
- By BUTTON_NEW = By.cssSelector(".slds-grid.slds-align-top div button:nth-child(1)");
- // BUTTON "New" in Fields and Relationships within an Object
- By BUTTON_NEW02 = By.cssSelector("div.slds-col.slds-no-flex.slds-grid.slds-align-top button:nth-child(1)");
- // BUTTON "SAVE", when creating New custom field
- By BUTTON_SAVE_CUSTOM_FIELD = By.cssSelector("div.pbWizardHeader div input:nth-child(3)");
- // OBJECT "Account" in: Object Manager > Objects and Fields
- By ACCOUNT_OBJECT = By.partialLinkText("Account");
- // OBJECT "Opportunity" in: Object Manager > Objects and Fields
- By OPPORTUNITY_OBJECT = By.linkText("Opportunity");
- // CUSTOM OBJECT "Robot Setup" in: Objects and Fields > Object Manager
- By ROBOT_SETUP_OBJECT = By.linkText("Robot Setup");
- // TEXT BOX "Field Label" in: New custom field / New custom object
- By MASTER_LABEL_TEXTBOX = By.id("MasterLabel");
- // TEXT BOX "Field Name" in: New custom field / New custom object
- By FIELD_NAME = By.id("DeveloperName");
- // TEXT BOX "Plural Label" in: New custom object
- By PLURAL_LABEL_TEXTBOX = By.id("PluralLabel");
- // By SEARCH_ITEM = By.cssSelector("[title='"+ SEARCH_TEXT +"'] mark");
- // ---------------------------------------------------------------
- // WebElements
- // ---------------------------------------------------------------
- public WebElement iframe(){
- wait.until(ExpectedConditions.visibilityOfElementLocated(IFRAME));
- return driver.findElement(IFRAME);
- }
- public WebElement button_Next01(){
- wait.until(ExpectedConditions.visibilityOfElementLocated(BUTTON_NEXT01));
- return driver.findElement(BUTTON_NEXT01);
- }
- public WebElement button_Next02(){
- wait.until(ExpectedConditions.visibilityOfElementLocated(BUTTON_NEXT02));
- return driver.findElement(BUTTON_NEXT02);
- }
- public WebElement button_New(){
- wait.until(ExpectedConditions.visibilityOfElementLocated(BUTTON_NEW));
- return driver.findElement(BUTTON_NEW);
- }
- public WebElement button_New02(){
- wait.until(ExpectedConditions.visibilityOfElementLocated(BUTTON_NEW02));
- return driver.findElement(BUTTON_NEW02);
- }
- public WebElement button_SaveCustomField(){
- wait.until(ExpectedConditions.visibilityOfElementLocated(BUTTON_SAVE_CUSTOM_FIELD));
- return driver.findElement(BUTTON_SAVE_CUSTOM_FIELD);
- }
- public WebElement account_Object(){
- wait.until(ExpectedConditions.visibilityOfElementLocated(ACCOUNT_OBJECT));
- return driver.findElement(ACCOUNT_OBJECT);
- }
- public WebElement opportunity_Object(){
- wait.until(ExpectedConditions.visibilityOfElementLocated(OPPORTUNITY_OBJECT));
- return driver.findElement(OPPORTUNITY_OBJECT);
- }
- public WebElement robotSetup_Object(){
- wait.until(ExpectedConditions.visibilityOfElementLocated(ROBOT_SETUP_OBJECT));
- return driver.findElement(ROBOT_SETUP_OBJECT);
- }
- public WebElement masterLabel_Textbox(){
- wait.until(ExpectedConditions.visibilityOfElementLocated(MASTER_LABEL_TEXTBOX));
- return driver.findElement(MASTER_LABEL_TEXTBOX);
- }
- public WebElement fieldName_Textbox(){
- wait.until(ExpectedConditions.visibilityOfElementLocated(FIELD_NAME));
- return driver.findElement(FIELD_NAME);
- }
- public WebElement pluralLabel_Textbox(){
- wait.until(ExpectedConditions.visibilityOfElementLocated(PLURAL_LABEL_TEXTBOX));
- return driver.findElement(PLURAL_LABEL_TEXTBOX);
- }
- // public WebElement searchItem(String searchText){
- // wait.until(ExpectedConditions.visibilityOfElementLocated(SEARCH_ITEM));
- // return driver.findElement(SEARCH_ITEM);
- // }
- // ---------------------------------------------------------------
- // Actions on WebElements
- // ---------------------------------------------------------------
- public void clickNextButton01(){
- WebElement elem = this.button_Next01();
- elem.click();
- }
- public void clickNextButton02(){
- WebElement elem = this.button_Next02();
- elem.click();
- }
- public void clickNewButton(){
- WebElement elem = this.button_New();
- elem.click();
- }
- public void clickNewButton02(){
- WebElement elem = this.button_New02();
- elem.click();
- }
- public void clickSaveCustomField(){
- WebElement elem = this.button_SaveCustomField();
- elem.click();
- }
- public void clickAccountObject(){
- WebElement elem = this.account_Object();
- elem.click();
- }
- public void clickOpportunityObject(){
- WebElement elem = this.opportunity_Object();
- elem.click();
- }
- public void clickRobotSetupObject(){
- WebElement elem = this.robotSetup_Object();
- elem.click();
- }
- public void clickMasterLabelTextbox(){
- WebElement elem = this.masterLabel_Textbox();
- elem.click();
- }
- public void clickFieldNameTextbox(){
- WebElement elem = this.fieldName_Textbox();
- elem.click();
- }
- public void clickPluralLabelTextbox(){
- WebElement elem = this.pluralLabel_Textbox();
- elem.click();
- }
- // public void clickSearchItem(){
- // WebElement elem = this.searchItem(SEARCH_TEXT);
- // elem.click();
- // }
- // ---------------------------------------------------------------
- // Methods
- // ---------------------------------------------------------------
- public void quickFindSearchAndSelect(String searchText) {
- LeftPanel leftPanel = new LeftPanel(driver);
- // SEARCH_TEXT = searchText;
- ArrayList tabs = new ArrayList(driver.getWindowHandles());
- driver.switchTo().window((String) tabs.get(1));
- // WebElement quickFindText = WebDriverUtils.findElement(driver, By.cssSelector("[placeholder=\"Quick Find\"]"));
- leftPanel.quickFind_Searchbox().clear();
- leftPanel.quickFind_Searchbox().sendKeys(searchText);
- //WebElement searchItem = WebDriverUtils.findElement(driver, By.cssSelector("[title='"+ searchText +"'] mark"));// ?????????????
- WebElement searchItem = leftPanel.searchItem(searchText);
- leftPanel.clickQuickFind_Item(searchText);
- logger.info("Navigating to "+ searchText +"...");
- // WebDriverUtils.click(driver, By.cssSelector("[title='"+ searchText +"'] mark"));
- leftPanel.clickQuickFind_Item(searchText);// searchItem.click();
- //WebElement iframe = WebDriverUtils.findElement(driver, By.cssSelector("iframe"), Duration.ofSeconds(20));
- driver.switchTo().frame(this.iframe());
- }
- public void quickFindSearchAndSelects(String searchText) {
- ArrayList tabs = new ArrayList(driver.getWindowHandles());
- driver.switchTo().window((String) tabs.get(1));
- //waitFor(2000);
- WebElement quickFindText = WebDriverUtils.findElement(driver, By.cssSelector("[placeholder=\"Quick Find\"]"));
- quickFindText.clear();
- quickFindText.sendKeys(searchText);
- WebElement searchItem = WebDriverUtils.findElement(driver, By.cssSelector("[title='"+ searchText +"'] mark"));
- logger.info("Navigating to "+ searchText +"...");
- WebDriverUtils.click(driver, By.cssSelector("[title='"+ searchText +"'] mark"));
- WebElement iframe = WebDriverUtils.findElement(driver, By.cssSelector("iframe"), Duration.ofSeconds(20));
- driver.switchTo().frame(iframe);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement