Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pageObjects.ProcessBuilder;
- import com.sforce.trailhead.tcdev.pages.AbstractPage;
- import com.sforce.trailhead.tcdev.util.WebDriverUtils;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.support.ui.ExpectedConditions;
- import org.openqa.selenium.support.ui.Select;
- import org.openqa.selenium.support.ui.WebDriverWait;
- /**
- * Page Object for New Process Builder
- */
- public class NewProcessBuilder extends AbstractPage {
- public NewProcessBuilder(WebDriver driver) {
- super(driver);
- }
- WebDriverWait wait = new WebDriverWait(driver, 30);
- // ---------------------------------------------------------------
- // Strings
- // ---------------------------------------------------------------
- public static final String THE_PROCESS_STARTS_WHEN_PICKLIST = "uiInput--select";
- public static final String PROCESS_START_OPTION_A_RECORD_CHANGES = "A record changes";
- public static final String CHOOSE_OBJECT_PICKLIST = "hasButton default input uiInput";
- public static final String CHOOSE_OBJECT_OPTION_ROBOT_SETEUP = "Robot Setup";
- public static final String FORMULA1_CONTENT = "(CONTAINS([Robot_Setup__c].Day_of_the_Week__c , \"Saturday\"))";
- public static final String ACTION_TYPES_PICKLIST = "(//input[@class='select uiInput uiInputSelect uiInput--default uiInput--select'])[3]";
- public static final String ACTION_NAME_TEXTBOX = "(input uiInput uiInputText uiInput--default uiInput--input)[2]";
- public static final String UPDATE_TO_MONDAY = "Update to Monday";
- public static final String ACTION_FIELDS_PICKLIST = "(\"hasButton default\")[2]";
- // ---------------------------------------------------------------
- // Locators
- // ---------------------------------------------------------------
- //By NEW_PROCESS_BUILDER_BUTTON = By.cssSelector("div.processuicommonToolbar.processuimgntConsoleToolbar.processuimgntConsole.processuiLayout > button > span");
- By NEW_PROCESS_BUILDER_BUTTON = By.cssSelector(".uiButton--brand.uiButton");
- By PROCESS_NAME_TEXTBOX = By.id("processName");
- By API_NAME_TEXTBOX = By.id("apiName");
- By PROCESS_STARTS_WHEN_PICKLIST = By.className("uiInput--select");
- By SAVE_BUTTON = By.cssSelector("div.modal-footer.slds-modal__footer > button.slds-button.slds-button--neutral.uiButton--default.uiButton--brand.uiButton > span");
- By ADD_OBJECT_BUTTON = By.cssSelector("[title='Add Object'] span");
- By CHOOSE_OBJECTS_PICKLIST = By.cssSelector(".hasButton.default.input");
- By WHEN_A_RECORD_IS_CREATED_OR_EDITED_RADIOBUTTON = By.cssSelector("div.body.processuicommonPanel.processuicommonTriggerPanel.showPanel > div.panelBody.normal > div > div > fieldset > div > div:nth-child(3) > div > label");
- By SAVE_CHOOSE_OBJECT_BUTTON = By.cssSelector("div.body.processuicommonPanel.processuicommonTriggerPanel.showPanel > div.panelButtons.normal > button.slds-button.slds-button--neutral.saveButton.uiButton--default.uiButton--brand.uiButton");
- By ADD_CRITERIA_BUTTON = By.id("add");
- By FORMULA_EVALUATES_TO_TRUE_RADIOBUTTON = By.cssSelector("div.body.processuicommonPanel.processuicommonOutcomePanel.showPanel > div.panelBody.normal > div > fieldset > div > div:nth-child(3) > div > label");
- By FORMULA_EDITOR = By.className("uiInput--default uiInput--textarea");
- By SAVE_FORMULA_BUTTON = By.cssSelector(".showPanel > div.panelButtons.normal > button.slds-button.slds-button--neutral.saveButton.uiButton--default.uiButton--brand.uiButton > span");
- By ADD_ACTION_BUTTON = By.className("addElement disabled processuicommonCanvasElement");
- By ACTION_TYPE_PICKLIST = By.className("select uiInput uiInputSelect uiInput--default uiInput--select"); //3
- By CRITERIA_NAME_TEXTFIELD = By.className("Button"); //2
- By PAGE_BODY = By.className("body processuiruleRuleCanvas");
- By ACTION_NAME = By.className("input uiInput uiInputText uiInput--default uiInput--input");
- By RECORD_TYPE_SELECT_BOX = By.cssSelector("div.objectPicker.processuicommonActionTypeRecordUpdate > label > div > div > a > div > div.bBody > span");
- By SELECT_A_RECORD_TO_UPDATE_MODAL = By.className("title slds-text-heading--medium");
- By SELECT_ROBOT_SETUP_TO_UPDATE = By.cssSelector("div.modal-body.scrollable.slds-modal__content.slds-p-around--medium > fieldset > div:nth-child(2) > label");
- By CHOOSE_RECORD_BUTTON = By.cssSelector("div.modal-footer.slds-modal__footer > button.slds-button.slds-button--neutral.uiButton--default.uiButton--brand.uiButton");
- By SAVE_ACTION_BUTTON = By.cssSelector("div.body.processuicommonPanel.processuicommonActionPanel.showPanel > div.panelButtons.normal > button.slds-button.slds-button--neutral.saveButton.uiButton--default.uiButton--brand.uiButton");
- By JUST_UPDATE_THE_RECORDS_RADIOBUTTON = By.cssSelector("div.panelBody.normal > div > div > div:nth-child(3) > fieldset > div > div:nth-child(3) > div > label");
- By ACTION_FIELD_PICKLIST = By.className("hasButton default");
- By ACTION_FIELD_TYPE = By.cssSelector("select uiInput uiInputSelect uiInput.default uiInput--select"); //[7]
- By ACTION_FORMULA = By.className("uiInputTextArea"); //2
- By USE_THIS_FORMULA_BUTTON = By.className(".slds-button--brand.saveButton.uiButton--default.uiButton--neutral.uiButton");
- By ACTIVATE_PROCESS_BUILDER = By.cssSelector(".activate.uiButton--default.uiButton--brand.uiButton > span");
- // ---------------------------------------------------------------
- // WebElements
- // ---------------------------------------------------------------
- public WebElement newProcessBuilder() {
- wait.until(ExpectedConditions. visibilityOfElementLocated(NEW_PROCESS_BUILDER_BUTTON));
- return driver.findElement(NEW_PROCESS_BUILDER_BUTTON);
- }
- public WebElement processName() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(PROCESS_NAME_TEXTBOX));
- return driver.findElement(PROCESS_NAME_TEXTBOX);
- }
- public WebElement apiName() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(API_NAME_TEXTBOX));
- return driver.findElement(API_NAME_TEXTBOX);
- }
- public WebElement processStartSelector() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(PROCESS_STARTS_WHEN_PICKLIST));
- return driver.findElement(PROCESS_STARTS_WHEN_PICKLIST);
- }
- public WebElement saveButton() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(SAVE_BUTTON));
- return driver.findElement(SAVE_BUTTON);
- }
- public WebElement addObjectButton() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(ADD_OBJECT_BUTTON));
- return driver.findElement(ADD_OBJECT_BUTTON);
- }
- public WebElement chooseObjectPicklist() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(CHOOSE_OBJECTS_PICKLIST));
- return driver.findElement(CHOOSE_OBJECTS_PICKLIST);
- }
- public WebElement whenARecordCreatedOrEdited() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(WHEN_A_RECORD_IS_CREATED_OR_EDITED_RADIOBUTTON));
- return driver.findElement(WHEN_A_RECORD_IS_CREATED_OR_EDITED_RADIOBUTTON);
- }
- public WebElement saveChooseObject() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(SAVE_CHOOSE_OBJECT_BUTTON));
- return driver.findElement(SAVE_CHOOSE_OBJECT_BUTTON);
- }
- public WebElement addCriteria() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(ADD_CRITERIA_BUTTON));
- return driver.findElement(ADD_CRITERIA_BUTTON);
- }
- public WebElement formulaEvalTrue() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(FORMULA_EVALUATES_TO_TRUE_RADIOBUTTON));
- return driver.findElement(FORMULA_EVALUATES_TO_TRUE_RADIOBUTTON);
- }
- public WebElement formulaEditor() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(FORMULA_EDITOR));
- return driver.findElement(FORMULA_EDITOR);
- }
- public WebElement saveFormulaButton() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(SAVE_FORMULA_BUTTON));
- return driver.findElement(SAVE_FORMULA_BUTTON);
- }
- public WebElement addActionButton() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(ADD_ACTION_BUTTON));
- return driver.findElement(ADD_ACTION_BUTTON);
- }
- public WebElement actionTypePicklist() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(ACTION_TYPE_PICKLIST));
- return driver.findElements(ACTION_TYPE_PICKLIST).get(3);
- }
- public WebElement criteriaName() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(CRITERIA_NAME_TEXTFIELD));
- return driver.findElements(CRITERIA_NAME_TEXTFIELD).get(2);
- }
- public WebElement pageBody() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(PAGE_BODY));
- return driver.findElement(PAGE_BODY);
- }
- public WebElement actionName() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(ACTION_NAME)); //??
- return driver.findElements(ACTION_NAME).get(2);
- }
- public WebElement recordTypeSelectBox() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(RECORD_TYPE_SELECT_BOX)); //??
- return driver.findElements(RECORD_TYPE_SELECT_BOX).get(2);
- }
- public WebElement recordToUpdateModal() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(SELECT_A_RECORD_TO_UPDATE_MODAL));
- return driver.findElement(SELECT_A_RECORD_TO_UPDATE_MODAL);
- }
- public WebElement selectRobotSetupToUpdate() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(SELECT_ROBOT_SETUP_TO_UPDATE));
- return driver.findElement(SELECT_ROBOT_SETUP_TO_UPDATE);
- }
- public WebElement chooseRecordButton() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(CHOOSE_RECORD_BUTTON));
- return driver.findElement(CHOOSE_RECORD_BUTTON);
- }
- public WebElement saveActionButton() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(SAVE_ACTION_BUTTON));
- return driver.findElement(SAVE_ACTION_BUTTON);
- }
- public WebElement justUpdateTheRecords() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(JUST_UPDATE_THE_RECORDS_RADIOBUTTON));
- return driver.findElement(JUST_UPDATE_THE_RECORDS_RADIOBUTTON);
- }
- public WebElement actionFieldPicklist() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(ACTION_FIELD_PICKLIST)); //??
- return driver.findElements(ACTION_FIELD_PICKLIST).get(2);
- }
- public WebElement actionFieldType() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(ACTION_FIELD_TYPE)); //??
- return driver.findElements(ACTION_FIELD_TYPE).get(7);
- }
- public WebElement actionFormula() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(ACTION_FORMULA)); //??
- return driver.findElements(ACTION_FORMULA).get(2);
- }
- public WebElement useThisFormula() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(USE_THIS_FORMULA_BUTTON)); //??
- return driver.findElement(USE_THIS_FORMULA_BUTTON);
- }
- public WebElement activateProcessBuilder() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(ACTIVATE_PROCESS_BUILDER)); //??
- return driver.findElement(ACTIVATE_PROCESS_BUILDER);
- }
- // ---------------------------------------------------------------
- // Actions on WebElements
- // ---------------------------------------------------------------
- public void clickNewProcessBuilder() {
- WebElement elem = this.newProcessBuilder();
- elem.click();
- }
- public void clickProcessName() {
- WebElement elem = this.processName();
- elem.click();
- }
- public void clickApiName() {
- WebElement elem = this.apiName();
- elem.click();
- }
- public void clickProcessStartSelector() {
- WebElement elem = this.processStartSelector();
- elem.click();
- }
- public void clickSaveButton() {
- WebElement elem = this.saveButton();
- elem.click();
- }
- public void clickAddObjectButton() {
- WebElement elem = this.addObjectButton();
- elem.click();
- }
- public void clickChooseObject() {
- WebElement elem = this.addObjectButton();
- elem.click();
- }
- public void clickWhenARecordCreatedOrEdited() {
- WebElement elem = this.whenARecordCreatedOrEdited();
- elem.click();
- }
- public void clickSaveChooseObject() {
- WebElement elem = this.saveChooseObject();
- elem.click();
- }
- public void clickCriteriaName() {
- WebElement elem = this.criteriaName();
- elem.click();
- }
- public void clickFormulaEvalTrue() {
- WebElement elem = this.formulaEvalTrue();
- elem.click();
- }
- public void clickFormulaEditor() {
- WebElement elem = this.formulaEditor();
- elem.click();
- }
- public void clickFormulaSaveButton() {
- WebElement elem = this.saveFormulaButton();
- elem.click();
- }
- public void clickAddActionButton() {
- WebElement elem = this.addActionButton();
- elem.click();
- }
- public void clickActionTypePicklist() {
- WebElement elem = this.actionTypePicklist();
- elem.click();
- }
- public void clickChooseObjectPicklist() {
- WebElement elem = this.chooseObjectPicklist();
- elem.click();
- }
- public void clickPageBody() {
- WebElement elem = this.pageBody();
- elem.click();
- }
- public void clickActionName() {
- WebElement elem = this.actionName();
- elem.click();
- }
- public void clickRecordTypeSelectBox() {
- WebElement elem = this.recordTypeSelectBox();
- elem.click();
- }
- public void clickRecordToUpdateModal() {
- WebElement elem = this.recordToUpdateModal();
- elem.click();
- }
- public void clickSelectRobotSetupToUpdate() {
- WebElement elem = this.selectRobotSetupToUpdate();
- elem.click();
- }
- public void clickChooseRecordButton() {
- WebElement elem = this.chooseRecordButton();
- elem.click();
- }
- public void clickSaveActionButton() {
- WebElement elem = this.saveActionButton();
- elem.click();
- }
- public void clickJustUpdateTheRecords() {
- WebElement elem = this.justUpdateTheRecords();
- elem.click();
- }
- public void clickActionFieldPicklist() {
- WebElement elem = this.actionFieldPicklist();
- elem.click();
- }
- public void clickActionFieldType() {
- WebElement elem = this.actionFieldType();
- elem.click();
- }
- public void clickActionFormula() {
- WebElement elem = this.actionFormula();
- elem.click();
- }
- public void clickUseThisFormula() {
- WebElement elem = this.useThisFormula();
- elem.click();
- }
- public void clickActivateProcessBuilder() {
- WebElement elem = this.activateProcessBuilder();
- elem.click();
- }
- // ---------------------------------------------------------------
- // Methods
- // ---------------------------------------------------------------
- public void selectOptionByClass(String selector, String option) {
- Select select = new Select(WebDriverUtils.findElement(driver, By.className(selector)));
- select.selectByVisibleText(option);
- }
- public void selectOptionByClasses(String selector, String option) {
- Select select = new Select(WebDriverUtils.findElement(driver, By.className(selector)));
- select.selectByVisibleText(option);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement