Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.82 KB | None | 0 0
  1. package pageObjects.ProcessBuilder;
  2.  
  3. import com.sforce.trailhead.tcdev.pages.AbstractPage;
  4. import com.sforce.trailhead.tcdev.util.WebDriverUtils;
  5. import org.openqa.selenium.By;
  6. import org.openqa.selenium.WebDriver;
  7. import org.openqa.selenium.WebElement;
  8. import org.openqa.selenium.support.ui.ExpectedConditions;
  9. import org.openqa.selenium.support.ui.Select;
  10. import org.openqa.selenium.support.ui.WebDriverWait;
  11.  
  12.  
  13. /**
  14. * Page Object for New Process Builder
  15. */
  16. public class NewProcessBuilder extends AbstractPage {
  17.  
  18. public NewProcessBuilder(WebDriver driver) {
  19. super(driver);
  20. }
  21.  
  22. WebDriverWait wait = new WebDriverWait(driver, 30);
  23.  
  24.  
  25. // ---------------------------------------------------------------
  26. // Strings
  27. // ---------------------------------------------------------------
  28. public static final String THE_PROCESS_STARTS_WHEN_PICKLIST = "uiInput--select";
  29. public static final String PROCESS_START_OPTION_A_RECORD_CHANGES = "A record changes";
  30. public static final String CHOOSE_OBJECT_PICKLIST = "hasButton default input uiInput";
  31. public static final String CHOOSE_OBJECT_OPTION_ROBOT_SETEUP = "Robot Setup";
  32. public static final String FORMULA1_CONTENT = "(CONTAINS([Robot_Setup__c].Day_of_the_Week__c , \"Saturday\"))";
  33. public static final String ACTION_TYPES_PICKLIST = "(//input[@class='select uiInput uiInputSelect uiInput--default uiInput--select'])[3]";
  34. public static final String ACTION_NAME_TEXTBOX = "(input uiInput uiInputText uiInput--default uiInput--input)[2]";
  35. public static final String UPDATE_TO_MONDAY = "Update to Monday";
  36. public static final String ACTION_FIELDS_PICKLIST = "(\"hasButton default\")[2]";
  37.  
  38.  
  39.  
  40.  
  41. // ---------------------------------------------------------------
  42. // Locators
  43. // ---------------------------------------------------------------
  44. //By NEW_PROCESS_BUILDER_BUTTON = By.cssSelector("div.processuicommonToolbar.processuimgntConsoleToolbar.processuimgntConsole.processuiLayout > button > span");
  45. By NEW_PROCESS_BUILDER_BUTTON = By.cssSelector(".uiButton--brand.uiButton");
  46. By PROCESS_NAME_TEXTBOX = By.id("processName");
  47. By API_NAME_TEXTBOX = By.id("apiName");
  48. By PROCESS_STARTS_WHEN_PICKLIST = By.className("uiInput--select");
  49. By SAVE_BUTTON = By.cssSelector("div.modal-footer.slds-modal__footer > button.slds-button.slds-button--neutral.uiButton--default.uiButton--brand.uiButton > span");
  50. By ADD_OBJECT_BUTTON = By.cssSelector("[title='Add Object'] span");
  51. By CHOOSE_OBJECTS_PICKLIST = By.cssSelector(".hasButton.default.input");
  52. 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");
  53. 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");
  54. By ADD_CRITERIA_BUTTON = By.id("add");
  55. 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");
  56. By FORMULA_EDITOR = By.className("uiInput--default uiInput--textarea");
  57. By SAVE_FORMULA_BUTTON = By.cssSelector(".showPanel > div.panelButtons.normal > button.slds-button.slds-button--neutral.saveButton.uiButton--default.uiButton--brand.uiButton > span");
  58. By ADD_ACTION_BUTTON = By.className("addElement disabled processuicommonCanvasElement");
  59. By ACTION_TYPE_PICKLIST = By.className("select uiInput uiInputSelect uiInput--default uiInput--select"); //3
  60. By CRITERIA_NAME_TEXTFIELD = By.className("Button"); //2
  61. By PAGE_BODY = By.className("body processuiruleRuleCanvas");
  62. By ACTION_NAME = By.className("input uiInput uiInputText uiInput--default uiInput--input");
  63. By RECORD_TYPE_SELECT_BOX = By.cssSelector("div.objectPicker.processuicommonActionTypeRecordUpdate > label > div > div > a > div > div.bBody > span");
  64. By SELECT_A_RECORD_TO_UPDATE_MODAL = By.className("title slds-text-heading--medium");
  65. 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");
  66. By CHOOSE_RECORD_BUTTON = By.cssSelector("div.modal-footer.slds-modal__footer > button.slds-button.slds-button--neutral.uiButton--default.uiButton--brand.uiButton");
  67. 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");
  68. 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");
  69. By ACTION_FIELD_PICKLIST = By.className("hasButton default");
  70. By ACTION_FIELD_TYPE = By.cssSelector("select uiInput uiInputSelect uiInput.default uiInput--select"); //[7]
  71. By ACTION_FORMULA = By.className("uiInputTextArea"); //2
  72. By USE_THIS_FORMULA_BUTTON = By.className(".slds-button--brand.saveButton.uiButton--default.uiButton--neutral.uiButton");
  73. By ACTIVATE_PROCESS_BUILDER = By.cssSelector(".activate.uiButton--default.uiButton--brand.uiButton > span");
  74.  
  75.  
  76.  
  77. // ---------------------------------------------------------------
  78. // WebElements
  79. // ---------------------------------------------------------------
  80. public WebElement newProcessBuilder() {
  81. wait.until(ExpectedConditions. visibilityOfElementLocated(NEW_PROCESS_BUILDER_BUTTON));
  82. return driver.findElement(NEW_PROCESS_BUILDER_BUTTON);
  83. }
  84.  
  85. public WebElement processName() {
  86. wait.until(ExpectedConditions.visibilityOfElementLocated(PROCESS_NAME_TEXTBOX));
  87. return driver.findElement(PROCESS_NAME_TEXTBOX);
  88. }
  89.  
  90. public WebElement apiName() {
  91. wait.until(ExpectedConditions.visibilityOfElementLocated(API_NAME_TEXTBOX));
  92. return driver.findElement(API_NAME_TEXTBOX);
  93. }
  94.  
  95. public WebElement processStartSelector() {
  96. wait.until(ExpectedConditions.visibilityOfElementLocated(PROCESS_STARTS_WHEN_PICKLIST));
  97. return driver.findElement(PROCESS_STARTS_WHEN_PICKLIST);
  98. }
  99.  
  100. public WebElement saveButton() {
  101. wait.until(ExpectedConditions.visibilityOfElementLocated(SAVE_BUTTON));
  102. return driver.findElement(SAVE_BUTTON);
  103. }
  104.  
  105. public WebElement addObjectButton() {
  106. wait.until(ExpectedConditions.visibilityOfElementLocated(ADD_OBJECT_BUTTON));
  107. return driver.findElement(ADD_OBJECT_BUTTON);
  108. }
  109.  
  110. public WebElement chooseObjectPicklist() {
  111. wait.until(ExpectedConditions.visibilityOfElementLocated(CHOOSE_OBJECTS_PICKLIST));
  112. return driver.findElement(CHOOSE_OBJECTS_PICKLIST);
  113. }
  114.  
  115. public WebElement whenARecordCreatedOrEdited() {
  116. wait.until(ExpectedConditions.visibilityOfElementLocated(WHEN_A_RECORD_IS_CREATED_OR_EDITED_RADIOBUTTON));
  117. return driver.findElement(WHEN_A_RECORD_IS_CREATED_OR_EDITED_RADIOBUTTON);
  118. }
  119.  
  120. public WebElement saveChooseObject() {
  121. wait.until(ExpectedConditions.visibilityOfElementLocated(SAVE_CHOOSE_OBJECT_BUTTON));
  122. return driver.findElement(SAVE_CHOOSE_OBJECT_BUTTON);
  123. }
  124.  
  125. public WebElement addCriteria() {
  126. wait.until(ExpectedConditions.visibilityOfElementLocated(ADD_CRITERIA_BUTTON));
  127. return driver.findElement(ADD_CRITERIA_BUTTON);
  128. }
  129.  
  130.  
  131. public WebElement formulaEvalTrue() {
  132. wait.until(ExpectedConditions.visibilityOfElementLocated(FORMULA_EVALUATES_TO_TRUE_RADIOBUTTON));
  133. return driver.findElement(FORMULA_EVALUATES_TO_TRUE_RADIOBUTTON);
  134. }
  135.  
  136. public WebElement formulaEditor() {
  137. wait.until(ExpectedConditions.visibilityOfElementLocated(FORMULA_EDITOR));
  138. return driver.findElement(FORMULA_EDITOR);
  139. }
  140.  
  141. public WebElement saveFormulaButton() {
  142. wait.until(ExpectedConditions.visibilityOfElementLocated(SAVE_FORMULA_BUTTON));
  143. return driver.findElement(SAVE_FORMULA_BUTTON);
  144. }
  145.  
  146. public WebElement addActionButton() {
  147. wait.until(ExpectedConditions.visibilityOfElementLocated(ADD_ACTION_BUTTON));
  148. return driver.findElement(ADD_ACTION_BUTTON);
  149. }
  150.  
  151. public WebElement actionTypePicklist() {
  152. wait.until(ExpectedConditions.visibilityOfElementLocated(ACTION_TYPE_PICKLIST));
  153. return driver.findElements(ACTION_TYPE_PICKLIST).get(3);
  154. }
  155.  
  156. public WebElement criteriaName() {
  157. wait.until(ExpectedConditions.visibilityOfElementLocated(CRITERIA_NAME_TEXTFIELD));
  158. return driver.findElements(CRITERIA_NAME_TEXTFIELD).get(2);
  159. }
  160.  
  161. public WebElement pageBody() {
  162. wait.until(ExpectedConditions.visibilityOfElementLocated(PAGE_BODY));
  163. return driver.findElement(PAGE_BODY);
  164. }
  165.  
  166. public WebElement actionName() {
  167. wait.until(ExpectedConditions.visibilityOfElementLocated(ACTION_NAME)); //??
  168. return driver.findElements(ACTION_NAME).get(2);
  169. }
  170.  
  171. public WebElement recordTypeSelectBox() {
  172. wait.until(ExpectedConditions.visibilityOfElementLocated(RECORD_TYPE_SELECT_BOX)); //??
  173. return driver.findElements(RECORD_TYPE_SELECT_BOX).get(2);
  174. }
  175.  
  176. public WebElement recordToUpdateModal() {
  177. wait.until(ExpectedConditions.visibilityOfElementLocated(SELECT_A_RECORD_TO_UPDATE_MODAL));
  178. return driver.findElement(SELECT_A_RECORD_TO_UPDATE_MODAL);
  179. }
  180.  
  181. public WebElement selectRobotSetupToUpdate() {
  182. wait.until(ExpectedConditions.visibilityOfElementLocated(SELECT_ROBOT_SETUP_TO_UPDATE));
  183. return driver.findElement(SELECT_ROBOT_SETUP_TO_UPDATE);
  184. }
  185.  
  186. public WebElement chooseRecordButton() {
  187. wait.until(ExpectedConditions.visibilityOfElementLocated(CHOOSE_RECORD_BUTTON));
  188. return driver.findElement(CHOOSE_RECORD_BUTTON);
  189. }
  190.  
  191. public WebElement saveActionButton() {
  192. wait.until(ExpectedConditions.visibilityOfElementLocated(SAVE_ACTION_BUTTON));
  193. return driver.findElement(SAVE_ACTION_BUTTON);
  194. }
  195.  
  196. public WebElement justUpdateTheRecords() {
  197. wait.until(ExpectedConditions.visibilityOfElementLocated(JUST_UPDATE_THE_RECORDS_RADIOBUTTON));
  198. return driver.findElement(JUST_UPDATE_THE_RECORDS_RADIOBUTTON);
  199. }
  200.  
  201. public WebElement actionFieldPicklist() {
  202. wait.until(ExpectedConditions.visibilityOfElementLocated(ACTION_FIELD_PICKLIST)); //??
  203. return driver.findElements(ACTION_FIELD_PICKLIST).get(2);
  204. }
  205.  
  206. public WebElement actionFieldType() {
  207. wait.until(ExpectedConditions.visibilityOfElementLocated(ACTION_FIELD_TYPE)); //??
  208. return driver.findElements(ACTION_FIELD_TYPE).get(7);
  209. }
  210.  
  211. public WebElement actionFormula() {
  212. wait.until(ExpectedConditions.visibilityOfElementLocated(ACTION_FORMULA)); //??
  213. return driver.findElements(ACTION_FORMULA).get(2);
  214. }
  215.  
  216. public WebElement useThisFormula() {
  217. wait.until(ExpectedConditions.visibilityOfElementLocated(USE_THIS_FORMULA_BUTTON)); //??
  218. return driver.findElement(USE_THIS_FORMULA_BUTTON);
  219. }
  220.  
  221. public WebElement activateProcessBuilder() {
  222. wait.until(ExpectedConditions.visibilityOfElementLocated(ACTIVATE_PROCESS_BUILDER)); //??
  223. return driver.findElement(ACTIVATE_PROCESS_BUILDER);
  224. }
  225.  
  226.  
  227. // ---------------------------------------------------------------
  228. // Actions on WebElements
  229. // ---------------------------------------------------------------
  230. public void clickNewProcessBuilder() {
  231. WebElement elem = this.newProcessBuilder();
  232. elem.click();
  233. }
  234.  
  235. public void clickProcessName() {
  236. WebElement elem = this.processName();
  237. elem.click();
  238. }
  239.  
  240. public void clickApiName() {
  241. WebElement elem = this.apiName();
  242. elem.click();
  243. }
  244.  
  245. public void clickProcessStartSelector() {
  246. WebElement elem = this.processStartSelector();
  247. elem.click();
  248. }
  249.  
  250. public void clickSaveButton() {
  251. WebElement elem = this.saveButton();
  252. elem.click();
  253. }
  254.  
  255. public void clickAddObjectButton() {
  256. WebElement elem = this.addObjectButton();
  257. elem.click();
  258. }
  259.  
  260. public void clickChooseObject() {
  261. WebElement elem = this.addObjectButton();
  262. elem.click();
  263. }
  264.  
  265. public void clickWhenARecordCreatedOrEdited() {
  266. WebElement elem = this.whenARecordCreatedOrEdited();
  267. elem.click();
  268. }
  269.  
  270. public void clickSaveChooseObject() {
  271. WebElement elem = this.saveChooseObject();
  272. elem.click();
  273. }
  274.  
  275. public void clickCriteriaName() {
  276. WebElement elem = this.criteriaName();
  277. elem.click();
  278. }
  279.  
  280. public void clickFormulaEvalTrue() {
  281. WebElement elem = this.formulaEvalTrue();
  282. elem.click();
  283. }
  284.  
  285. public void clickFormulaEditor() {
  286. WebElement elem = this.formulaEditor();
  287. elem.click();
  288. }
  289.  
  290. public void clickFormulaSaveButton() {
  291. WebElement elem = this.saveFormulaButton();
  292. elem.click();
  293. }
  294.  
  295. public void clickAddActionButton() {
  296. WebElement elem = this.addActionButton();
  297. elem.click();
  298. }
  299.  
  300. public void clickActionTypePicklist() {
  301. WebElement elem = this.actionTypePicklist();
  302. elem.click();
  303. }
  304.  
  305. public void clickChooseObjectPicklist() {
  306. WebElement elem = this.chooseObjectPicklist();
  307. elem.click();
  308. }
  309.  
  310. public void clickPageBody() {
  311. WebElement elem = this.pageBody();
  312. elem.click();
  313. }
  314.  
  315. public void clickActionName() {
  316. WebElement elem = this.actionName();
  317. elem.click();
  318. }
  319.  
  320. public void clickRecordTypeSelectBox() {
  321. WebElement elem = this.recordTypeSelectBox();
  322. elem.click();
  323. }
  324.  
  325. public void clickRecordToUpdateModal() {
  326. WebElement elem = this.recordToUpdateModal();
  327. elem.click();
  328. }
  329.  
  330. public void clickSelectRobotSetupToUpdate() {
  331. WebElement elem = this.selectRobotSetupToUpdate();
  332. elem.click();
  333. }
  334.  
  335. public void clickChooseRecordButton() {
  336. WebElement elem = this.chooseRecordButton();
  337. elem.click();
  338. }
  339.  
  340. public void clickSaveActionButton() {
  341. WebElement elem = this.saveActionButton();
  342. elem.click();
  343. }
  344.  
  345. public void clickJustUpdateTheRecords() {
  346. WebElement elem = this.justUpdateTheRecords();
  347. elem.click();
  348. }
  349.  
  350. public void clickActionFieldPicklist() {
  351. WebElement elem = this.actionFieldPicklist();
  352. elem.click();
  353. }
  354.  
  355. public void clickActionFieldType() {
  356. WebElement elem = this.actionFieldType();
  357. elem.click();
  358. }
  359.  
  360. public void clickActionFormula() {
  361. WebElement elem = this.actionFormula();
  362. elem.click();
  363. }
  364.  
  365. public void clickUseThisFormula() {
  366. WebElement elem = this.useThisFormula();
  367. elem.click();
  368. }
  369.  
  370. public void clickActivateProcessBuilder() {
  371. WebElement elem = this.activateProcessBuilder();
  372. elem.click();
  373. }
  374.  
  375.  
  376.  
  377. // ---------------------------------------------------------------
  378. // Methods
  379. // ---------------------------------------------------------------
  380. public void selectOptionByClass(String selector, String option) {
  381. Select select = new Select(WebDriverUtils.findElement(driver, By.className(selector)));
  382. select.selectByVisibleText(option);
  383. }
  384.  
  385. public void selectOptionByClasses(String selector, String option) {
  386. Select select = new Select(WebDriverUtils.findElement(driver, By.className(selector)));
  387. select.selectByVisibleText(option);
  388. }
  389.  
  390. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement