001 /** 002 * Copyright 2005-2013 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package edu.samplu.common; 017 018 import com.thoughtworks.selenium.SeleneseTestBase; 019 import edu.samplu.admin.test.AdminTmplMthdSTNavBase; 020 import org.apache.commons.lang.RandomStringUtils; 021 import org.apache.commons.logging.Log; 022 import org.apache.commons.logging.LogFactory; 023 import org.junit.After; 024 import org.junit.Before; 025 import org.junit.BeforeClass; 026 import org.junit.Rule; 027 import org.junit.rules.TestName; 028 import org.openqa.selenium.Alert; 029 import org.openqa.selenium.By; 030 import org.openqa.selenium.JavascriptExecutor; 031 import org.openqa.selenium.NoSuchElementException; 032 import org.openqa.selenium.WebDriver; 033 import org.openqa.selenium.WebElement; 034 import org.openqa.selenium.chrome.ChromeDriverService; 035 import org.openqa.selenium.interactions.Actions; 036 import org.openqa.selenium.remote.RemoteWebDriver; 037 import org.openqa.selenium.support.ui.Select; 038 039 import java.lang.reflect.Method; 040 import java.util.ArrayList; 041 import java.util.Calendar; 042 import java.util.LinkedList; 043 import java.util.List; 044 import java.util.Set; 045 import java.util.concurrent.TimeUnit; 046 047 import static org.junit.Assert.assertEquals; 048 049 /** 050 * <p> 051 * Originally used to upgrade UpgradedSeleniumITBase (Selenium 1.0) tests to WebDriver (Selenium 2.0). Now there is 052 * refactoring to be done: 053 * <ol> 054 * <li><a href="https://jira.kuali.org/browse/KULRICE-9206">KULRICE-9206</a> Replace literal strings used more than 3 times with Constants, Javadoc constant with constant value. 055 * <li>Extract duplicate waitAndClick...(CONSTANT) to waitAndClickConstant, Javadoc a <pre>{@link #CONSTANT}</pre>. 056 * <li>Replace large chunks of duplication</li> 057 * <li><a href="https://jira.kuali.org/browse/KULRICE-9205">KULRICE-9205</a> Invert dependencies on fields and extract methods to WebDriverUtil so inheritance doesn't have to be used for 058 * reuse. See WebDriverUtil.waitFor </li> 059 * <li>Extract Nav specific code?</li> 060 * <li>Rename to WebDriverAbstractSmokeTestBase</li> 061 * </ol> 062 * </p> 063 * <p>Calls to passed() probably don't belong in the methods reused here.</p> 064 * @author Kuali Rice Team (rice.collab@kuali.org) 065 */ 066 public abstract class WebDriverLegacyITBase implements Failable { //implements com.saucelabs.common.SauceOnDemandSessionIdProvider { 067 068 /** 069 * Administration 070 */ 071 public static final String ADMINISTRATION_LINK_TEXT = "Administration"; 072 073 /** 074 * Agenda Lookup 075 */ 076 public static final String AGENDA_LOOKUP_LINK_TEXT = "Agenda Lookup"; 077 078 /** 079 * "//input[@aria-invalid]" 080 */ 081 public static final String ARIA_INVALID_XPATH = "//input[@aria-invalid]"; 082 083 /** 084 * methodToCall.blanketApprove 085 */ 086 public static final String BLANKET_APPROVE_NAME = "methodToCall.blanketApprove"; 087 088 /** 089 * methodToCall.cancel 090 * different cancel than CANCEL2_XPATH 091 */ 092 public static final String CANCEL_NAME = "methodToCall.cancel"; 093 094 /** 095 * //a[contains(text(), 'ancel')] 096 * Different cancel than CANCEL_NAME 097 */ 098 public static final String CANCEL2_XPATH = "//a[contains(text(), 'ancel')]"; 099 100 /** 101 * //*[@title='close this window'] 102 */ 103 public static final String CLOSE_WINDOW_XPATH_TITLE = "//*[@title='close this window']"; 104 105 /** 106 * Collections 107 */ 108 public static final String COLLECTIONS_LINK_TEXT = "Collections"; 109 110 /** 111 * "Kuali :: Configuration Test View" 112 */ 113 public static final String CONFIGURATION_VIEW_WINDOW_TITLE = "Kuali :: Configuration Test View"; 114 115 /** 116 * (//a[contains(text(),'Configuration Test View')])[3] 117 */ 118 public static final String CONFIGURATION_VIEW_XPATH = "(//a[contains(text(),'Configuration Test View')])[3]"; 119 120 /** 121 * copy 122 */ 123 public static final String COPY_LINK_TEXT = "copy"; 124 125 /** 126 * New Document not submitted successfully 127 */ 128 public static final String CREATE_NEW_DOCUMENT_NOT_SUBMITTED_SUCCESSFULLY_MESSAGE_TEXT = "New Document not submitted successfully"; 129 130 /** 131 * //img[@alt='create new'] 132 */ 133 public static final String CREATE_NEW_XPATH = "//img[@alt='create new']"; 134 135 /** 136 * Default "long" wait period is 30 seconds. See REMOTE_PUBLIC_WAIT_SECONDS_PROPERTY to configure 137 */ 138 public static final int DEFAULT_WAIT_SEC = 30; 139 140 /** 141 * //div[@class='left-errmsg-tab']/div/div 142 */ 143 public static final String DIV_LEFT_ERRMSG = "//div[@class='left-errmsg-tab']/div/div"; 144 145 /** 146 * //input[@id='document.newMaintainableObject.code'] 147 */ 148 public static final String DOC_CODE_XPATH = "//input[@id='document.newMaintainableObject.code']"; 149 150 /** 151 * //div[@id='headerarea']/div/table/tbody/tr[1]/td[1] 152 */ 153 public static final String DOC_ID_XPATH = "//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]"; 154 155 /** 156 * //table[@id='row']/tbody/tr[1]/td[1 157 */ 158 public static final String DOC_ID_XPATH_2 = "//table[@id='row']/tbody/tr[1]/td[1]"; 159 160 /** 161 * //table[@id='row']/tbody/tr[1]/td[1]/a 162 */ 163 public static final String DOC_ID_XPATH_3 ="//table[@id='row']/tbody/tr[1]/td[1]/a"; 164 165 /** 166 * //input[@id='document.documentHeader.documentDescription'] 167 */ 168 public static final String DOC_DESCRIPTION_XPATH ="//input[@id='document.documentHeader.documentDescription']"; 169 170 /** 171 * "//img[@alt='doc search'] 172 */ 173 public static final String DOC_SEARCH_XPATH = "//img[@alt='doc search']"; 174 175 /** 176 * //a[@title='Document Search'] 177 */ 178 public static final String DOC_SEARCH_XPATH_TITLE = "//a[@title='Document Search']"; 179 180 /** 181 * ENROUTE 182 */ 183 public static final String DOC_STATUS_ENROUTE = "ENROUTE"; 184 185 /** 186 * FINAL 187 */ 188 public static final String DOC_STATUS_FINAL = "FINAL"; 189 190 /** 191 * SAVED 192 */ 193 public static final String DOC_STATUS_SAVED = "SAVED"; 194 195 /** 196 * //table[@class='headerinfo']//tr[1]/td[2] 197 */ 198 public static final String DOC_STATUS_XPATH = "//table[@class='headerinfo']//tr[1]/td[2]"; 199 200 /** 201 * //table[@id='row']/tbody/tr[1]/td[4] 202 */ 203 public static final String DOC_STATUS_XPATH_2 = "//table[@id='row']/tbody/tr[1]/td[4]"; 204 205 /** 206 * //div[contains(div,'Document was successfully submitted.')] 207 */ 208 public static final String DOC_SUBMIT_SUCCESS_MSG_XPATH ="//div[contains(div,'Document was successfully submitted.')]"; 209 210 /** 211 * Set -Dremote.driver.dontTearDownOnFailure= 212 */ 213 public static final String DONT_TEAR_DOWN_ON_FAILURE_PROPERTY = "remote.driver.dontTearDownOnFailure"; 214 215 /** 216 * edit 217 */ 218 public static final String EDIT_LINK_TEXT = "edit"; 219 220 /** 221 * iframeportlet 222 */ 223 public static final String IFRAMEPORTLET_NAME = "iframeportlet"; 224 225 /** 226 * (//a[contains(text(),'Uif Components (Kitchen Sink)')])[2] 227 */ 228 public static final String KITCHEN_SINK_XPATH = "(//a[contains(text(),'Uif Components (Kitchen Sink)')])[2]"; 229 230 /** 231 * KRAD 232 */ 233 public static final String KRAD_XPATH = "KRAD"; 234 235 /** 236 * Kuali :: Uif Components 237 */ 238 public static final String KUALI_UIF_COMPONENTS_WINDOW_XPATH = "Kuali :: Uif Components"; 239 240 /** 241 * "Kuali :: View Title" 242 */ 243 public static final String KUALI_VIEW_WINDOW_TITLE = "Kuali :: View Title"; 244 245 /** 246 * //input[@name='imageField' and @value='Logout'] 247 */ 248 public static final String LOGOUT_XPATH = "//input[@name='imageField' and @value='Logout']"; 249 250 /** 251 * Main Menu 252 */ 253 public static final String MAIN_MENU_LINK_TEXT = "Main Menu"; 254 255 /** 256 * ^[\s\S]*error[\s\S]*$" 257 */ 258 public static final String REGEX_ERROR = "^[\\s\\S]*error[\\s\\S]*$"; 259 260 /** 261 * ^[\s\S]*valid[\s\S]*$ 262 */ 263 public static final String REGEX_VALID = "^.*\\bvalid\\b.*$"; 264 265 /** 266 * Set -Dremote.public.user= to the username to login as 267 */ 268 public static final String REMOTE_PUBLIC_USER_PROPERTY = "remote.public.user"; 269 270 /** 271 * You probably don't want to really be using a userpool, set -Dremote.public.userpool= to base url if you must. 272 */ 273 public static final String REMOTE_PUBLIC_USERPOOL_PROPERTY = "remote.public.userpool"; 274 275 /** 276 * Set -Dremote.public.wait.seconds to override DEFAULT_WAIT_SEC 277 */ 278 public static final String REMOTE_PUBLIC_WAIT_SECONDS_PROPERTY = "remote.public.wait.seconds"; 279 280 /** 281 * return value 282 */ 283 public static final String RETURN_VALUE_LINK_TEXT = "return value"; 284 285 /** 286 * Kuali :: Rich Messages 287 */ 288 public static final String RICH_MESSAGES_WINDOW_TITLE = "Kuali :: Rich Messages"; 289 290 /** 291 * //div[contains(div,'Document was successfully saved.')] 292 */ 293 public static final String SAVE_SUCCESSFUL_XPATH = "//div[contains(div,'Document was successfully saved.')]"; 294 295 /** 296 * //input[@name='methodToCall.save' and @alt='save'] 297 */ 298 public static final String SAVE_XPATH="//input[@name='methodToCall.save' and @alt='save']"; 299 300 /** 301 * KIM Screens 302 * //*[@name='methodToCall.save' and @alt='save'] 303 */ 304 public static final String SAVE_XPATH_2 = "//*[@name='methodToCall.save' and @alt='save']"; 305 306 /** 307 * //input[@title='search' and @name='methodToCall.search'] 308 */ 309 public static final String SAVE_XPATH_3 = "//input[@title='search' and @name='methodToCall.search']"; 310 311 /** 312 * //input[@name='methodToCall.search' and @value='search'] 313 */ 314 public static final String SEARCH_XPATH="//input[@name='methodToCall.search' and @value='search']"; 315 316 /** 317 * //input[@name='methodToCall.route' and @alt='submit'] 318 */ 319 public static final String SUBMIT_XPATH="//input[@name='methodToCall.route' and @alt='submit']"; 320 321 /** 322 * //input[@value='search'] 323 */ 324 public static final String SEARCH_XPATH_2 = "//input[@value='search']"; 325 326 /** 327 * //button[contains(text(),'Search')] 328 */ 329 public static final String SEARCH_XPATH_3 = "//button[contains(text(),'earch')]"; 330 331 /** 332 * div.uif-group.uif-collectionGroup.uif-tableCollectionGroup.uif-tableSubCollection.uif-disclosure span.uif-headerText-span 333 */ 334 public static final String SUB_COLLECTION_UIF_DISCLOSURE_SPAN_UIF_HEADER_TEXT_SPAN_XPATH = 335 "div.uif-group.uif-collectionGroup.uif-tableCollectionGroup.uif-tableSubCollection.uif-disclosure span.uif-headerText-span"; 336 337 /** 338 * timeout 339 */ 340 public static final String TIMEOUT_MESSAGE = "timeout"; 341 342 /** 343 * Travel Account Lookup 344 */ 345 public static final String TRAVEL_ACCOUNT_LOOKUP_LINK_TEXT = "Travel Account Lookup"; 346 347 /** 348 * Uif Components (Kitchen Sink) 349 */ 350 public static final String UIF_COMPONENTS_KITCHEN_SINK_LINK_TEXT = "Uif Components (Kitchen Sink)"; 351 352 /** 353 * (//a[contains(text(),'Validation Framework Demo')])[2] 354 */ 355 public static final String VALIDATION_FRAMEWORK_DEMO_XPATH = "(//a[contains(text(),'Validation Framework Demo')])[2]"; 356 357 /** 358 * Kuali :: Collection Totaling 359 */ 360 public static final String KUALI_COLLECTION_TOTALLING_WINDOW_XPATH = "Kuali :: Collection Totaling"; 361 362 /** 363 * //a[text()='Collection Totaling'] 364 */ 365 public static final String KUALI_COLLECTION_TOTALLING_XPATH = "//a[text()='Collection Totaling']"; 366 367 /** 368 * XML Ingester 369 */ 370 public static final String XML_INGESTER_LINK_TEXT = "XML Ingester"; 371 372 /** 373 * //a[@title='FiscalOfficerInfo Maintenance (New)'] 374 */ 375 public static final String FISCAL_OFFICER_INFO_MAINTENANCE_NEW_XPATH = "//a[@title='FiscalOfficerInfo Maintenance (New)']"; 376 377 static ChromeDriverService chromeDriverService; 378 379 protected WebDriver driver; 380 protected String user = "admin"; 381 protected int waitSeconds = DEFAULT_WAIT_SEC; 382 protected boolean passed = false; 383 protected String uiFramework = ITUtil.REMOTE_UIF_KNS; // default to KNS 384 385 private Log log = LogFactory.getLog(getClass()); 386 387 public @Rule 388 TestName testName = new TestName(); 389 390 protected String testMethodName; 391 392 protected String jGrowlHeader; 393 394 String sessionId = null; 395 396 /** 397 * If WebDriverUtil.chromeDriverCreateCheck() returns a ChromeDriverService, start it. 398 * {@link edu.samplu.common.WebDriverUtil#chromeDriverCreateCheck()} 399 * @throws Exception 400 */ 401 @BeforeClass 402 public static void chromeDriverService() throws Exception { 403 chromeDriverService = WebDriverUtil.chromeDriverCreateCheck(); 404 if (chromeDriverService != null) 405 chromeDriverService.start(); 406 } 407 408 /** 409 * Navigation tests should return ITUtil.PORTAL. 410 * Bookmark tests should return BOOKMARK_URL. 411 * 412 * @return string 413 */ 414 public abstract String getTestUrl(); 415 416 /** 417 * SeleniumBaseTest.fail from navigateInternal results in the test not being recorded as a failure in CI. 418 * @throws Exception 419 */ 420 protected void navigateInternal() throws Exception { 421 // just a hook...for now... 422 } 423 424 protected void startSession(Method method) throws Exception { 425 testMethodName = method.getName(); // TestNG 426 } 427 428 /** 429 * Failures in testSetup cause the test to not be recorded. Future plans are to extract form @Before and call at the start of each test. 430 * Setup the WebDriver properties, test, and login. Named testSetUp so it runs after TestNG's startSession(Method) 431 * {@link WebDriverUtil#determineUser(String)} 432 * {@link WebDriverUtil#setUp(String, String, String, String)} 433 */ 434 @Before 435 public void testSetUp() { 436 // TODO it would be better if all opening of urls and logging in was not done in setUp, failures in setUp case the test to not be recorded. extract to setUp and call first for all tests. 437 try { // Don't throw any exception from this methods, exceptions in Before annotations really mess up maven, surefire, or failsafe 438 if (testName != null && testName.getMethodName() != null) { // JUnit 439 testMethodName = testName.getMethodName(); 440 } 441 442 waitSeconds = Integer.parseInt(System.getProperty(REMOTE_PUBLIC_WAIT_SECONDS_PROPERTY, DEFAULT_WAIT_SEC + "")); 443 String givenUser = WebDriverUtil.determineUser(this.toString()); 444 if (givenUser != null) { 445 user = givenUser; 446 } 447 448 String testUrl = kulrice9804(); // https://jira.kuali.org/browse/KULRICE-9804 KNS Create new link absent when Bookmark URL requires Login 449 450 driver = WebDriverUtil.setUp(getUserName(), testUrl , getClass().getSimpleName(), testMethodName); 451 this.sessionId = ((RemoteWebDriver) driver).getSessionId().toString(); 452 453 jGrowlHeader = getClass().getSimpleName() + "." + testMethodName; 454 System.out.println(jGrowlHeader + " sessionId is " + sessionId); 455 WebDriverUtil.loginKradOrKns(driver, user, this); 456 457 navigateInternal(); // SeleniumBaseTest.fail from navigateInternal results in the test not being recorded as a failure in CI. 458 459 } catch (Throwable t) { 460 System.out.println("Throwable " + t.getMessage() + " in Before annotated method is very bad, ignoring and letting first method of test class to fail."); 461 t.printStackTrace(); 462 System.out.println("Throwable " + t.getMessage() + " in Before annotated method is very bad, ignoring and letting first method of test class to fail."); 463 } 464 } 465 466 /** 467 * // https://jira.kuali.org/browse/KULRICE-9804 KNS Create new link absent when Bookmark URL requires Login 468 * @return 469 */ 470 private String kulrice9804() { 471 String testUrl = getTestUrl(); 472 if (testUrl.contains(ITUtil.HIDE_RETURN_LINK) && 473 !testUrl.contains("&showMaintenanceLinks=true")) { 474 testUrl += "&showMaintenanceLinks=true"; 475 } 476 return testUrl; 477 } 478 479 /** 480 * Tear down test as configured. Do not allow exceptions to be thrown by tearDown, it kills the test run. 481 * {@link WebDriverUtil#tearDown(boolean, String, String, String)} 482 * {@link WebDriverLegacyITBase#REMOTE_PUBLIC_USERPOOL_PROPERTY} 483 * {@link edu.samplu.common.ITUtil#dontTearDownPropertyNotSet()} 484 * @throws Exception 485 */ 486 @After 487 public void tearDown() { 488 try { 489 if (!passed) { // TODO move to Failable.fail impl to included error message, when it is promoted to this class 490 jGrowlSticky("FAILURE!"); 491 } 492 493 WebDriverUtil.tearDown(passed, sessionId, this.toString().trim(), user); 494 } catch (Throwable t) { 495 System.out.println("Exception in tearDown " + t.getMessage()); 496 t.printStackTrace(); 497 } 498 499 finally { 500 try { 501 closeAndQuitWebDriver(); 502 } catch (Throwable t) { 503 System.out.println(t.getMessage() + " occured during tearDown, ignoring to avoid killing test run."); 504 t.printStackTrace(); 505 System.out.println(t.getMessage() + " occured during tearDown, ignoring to avoid killing test run."); 506 } 507 } 508 } 509 510 private void closeAndQuitWebDriver() { 511 if (driver != null) { 512 if (ITUtil.dontTearDownPropertyNotSet() && dontTearDownOnFailure()) { 513 driver.close(); 514 driver.quit(); 515 } 516 } 517 518 else { 519 System.out.println("WebDriver is null for " + this.getClass().toString() + ", if using saucelabs, has" + 520 " sauceleabs been uncommented in WebDriverUtil.java? If using a remote hub did you include the port?"); 521 } 522 } 523 524 private boolean dontTearDownOnFailure() { 525 if (!"n".equalsIgnoreCase(System.getProperty(DONT_TEAR_DOWN_ON_FAILURE_PROPERTY, "n"))) { 526 return passed; 527 } 528 return true; 529 } 530 531 /** 532 * Set the test state to passed, this method is required to be called at the conclusion of a test for the saucelabs state of a test to be updated. 533 */ 534 protected void passed() { 535 passed = true; 536 jGrowlSticky("Passed"); 537 } 538 539 protected void agendaLookupAssertions() throws Exception { 540 testLookUp(); 541 assertTextPresent("Rules"); 542 waitAndClick(By.xpath(CANCEL2_XPATH)); 543 } 544 545 /** 546 * Accept the javascript alert (clicking OK) 547 * 548 */ 549 protected void alertAccept() { 550 Alert alert = driver.switchTo().alert(); 551 //update is executed 552 alert.accept(); 553 } 554 555 /** 556 * Dismiss the javascript alert (clicking Cancel) 557 * 558 */ 559 protected void alertDismiss() { 560 Alert alert = driver.switchTo().alert(); 561 //update is executed 562 alert.dismiss(); 563 } 564 565 protected void assertAttributeClassRegexDoesntMatch(String field, String regex) throws InterruptedException { 566 Thread.sleep(1000); 567 String attribute = getAttributeByName(field, "class"); 568 SeleneseTestBase.assertTrue("getAttributeByName(" + field + ", \"class\") should not be null", attribute != null); 569 SeleneseTestBase.assertFalse("attribute " + attribute + " matches regex " + regex + " and it should not", 570 attribute.matches(regex)); 571 } 572 573 protected void assertAttributeClassRegexMatches(String field, String regex) throws InterruptedException { 574 Thread.sleep(1000); 575 String attribute = getAttributeByName(field, "class"); 576 SeleneseTestBase.assertTrue("getAttributeByName(" + field + ", \"class\") should not be null", attribute != null); 577 SeleneseTestBase.assertTrue("attribute " + attribute + " doesn't match regex " + regex, attribute.matches( 578 regex)); 579 } 580 581 protected void assertBlanketApproveButtonsPresent() { 582 assertElementPresentByName("methodToCall.route"); 583 assertElementPresentByName("methodToCall.save"); 584 assertElementPresentByName(BLANKET_APPROVE_NAME, "Blanket Approve button not present does " + user + " have permssion?"); 585 assertElementPresentByName("methodToCall.close"); 586 assertElementPresentByName(CANCEL_NAME); 587 } 588 589 protected void assertCancelConfirmation() throws InterruptedException { 590 waitAndClickByLinkText("Cancel"); 591 alertDismiss(); 592 } 593 594 protected void assertDocFinal(String docId) throws InterruptedException { 595 jiraAwareWaitFor(By.linkText("spreadsheet"), ""); 596 597 if (isElementPresent(By.linkText(docId))) { 598 SeleneseTestBase.assertEquals(DOC_STATUS_FINAL, getDocStatus()); 599 } else { 600 SeleneseTestBase.assertEquals(docId,driver.findElement(By.xpath(DOC_ID_XPATH_2))); 601 SeleneseTestBase.assertEquals(DOC_STATUS_FINAL, getDocStatus()); 602 } 603 } 604 605 protected void assertElementPresentByName(String name) { 606 driver.findElement(By.name(name)); 607 } 608 609 protected void assertElementPresentByName(String name, String message) { 610 try { 611 driver.findElement(By.name(name)); 612 } catch (Exception e) { 613 failableFail(name + " not present " + message); 614 } 615 } 616 617 protected void assertElementPresentByXpath(String locator) { 618 driver.findElement(By.xpath(locator)); 619 } 620 621 protected void assertElementPresentByXpath(String locator, String message) { 622 try { 623 driver.findElement(By.xpath(locator)); 624 } catch (Exception e) { 625 jiraAwareFail(By.xpath(locator), message, e); 626 } 627 } 628 629 protected void assertElementPresentByLinkText(String linkText) { 630 driver.findElement(By.linkText(linkText)); 631 } 632 633 protected void assertElementPresent(String locator) { 634 driver.findElement(By.cssSelector(locator)); 635 } 636 637 protected void assertFocusTypeBlurError(String field, String textToType) throws InterruptedException { 638 fireEvent(field, "focus"); 639 waitAndTypeByName(field, textToType); 640 fireEvent(field, "blur"); 641 Thread.sleep(200); 642 assertAttributeClassRegexMatches(field, REGEX_ERROR); 643 } 644 645 protected void assertFocusTypeBlurError(String field, String[] errorInputs) throws InterruptedException { 646 for (String errorInput: errorInputs) { 647 assertFocusTypeBlurError(field, errorInput); 648 clearTextByName(field); 649 } 650 } 651 652 protected void assertFocusTypeBlurValid(String field, String textToType) throws InterruptedException { 653 fireEvent(field, "focus"); 654 waitAndTypeByName(field, textToType); 655 fireEvent(field, "blur"); 656 Thread.sleep(200); 657 assertAttributeClassRegexMatches(field, REGEX_VALID); 658 assertAttributeClassRegexDoesntMatch(field, REGEX_ERROR); 659 } 660 661 protected void assertFocusTypeBlurValid(String field, String[] validInputs) throws InterruptedException { 662 for (String validInput: validInputs) { 663 assertFocusTypeBlurValid(field, validInput); 664 clearTextByName(field); 665 } 666 } 667 668 protected void assertIsVisibleByXpath(String xpath, String message) { 669 if (!isVisibleByXpath(xpath)) { 670 jiraAwareFail(xpath + " not visiable " + message); 671 } 672 } 673 674 protected void assertIsNotVisibleByXpath(String xpath, String message) { 675 if (isVisibleByXpath(xpath)) { 676 jiraAwareFail(xpath + " not visiable " + message); 677 } 678 } 679 680 protected void assertIsVisible(String locator) { 681 if (!isVisible(locator)) { 682 jiraAwareFail(locator + " is not visible and should be"); 683 } 684 } 685 686 protected void assertIsVisibleById(String id) { 687 if (!isVisibleById(id)) { 688 jiraAwareFail(id + " is not visible and should be"); 689 } 690 } 691 692 protected void assertIsNotVisible(String locator) { 693 if (isVisible(locator)) { 694 jiraAwareFail(locator + " is visible and should not be"); 695 } 696 } 697 698 protected void assertLabelFor(String forElementId, String labelText) { 699 SeleneseTestBase.assertEquals(labelText, getForLabelText(forElementId)); 700 } 701 702 /** 703 * Assert that clicking an element causes a popup window with a specific URL 704 * Uses Selenium's findElements method which does not throw a test exception if not found. 705 * @param by The locating mechanism of the element to be clicked 706 * @param windowName The name of the popup window 707 * @param url The URL of the popup window 708 */ 709 protected void assertPopUpWindowUrl(By by, String windowName, String url) { 710 driver.findElement(by).click(); 711 String parentWindowHandle = driver.getWindowHandle(); 712 // wait page to be loaded 713 driver.switchTo().window(windowName).findElements(By.tagName("head")); 714 SeleneseTestBase.assertEquals(url, driver.getCurrentUrl()); 715 driver.switchTo().window(parentWindowHandle); 716 } 717 718 protected void assertTableLayout() { 719 String pageSource = driver.getPageSource(); 720 SeleneseTestBase.assertTrue(pageSource.contains("Table Layout")); 721 SeleneseTestBase.assertTrue(pageSource.contains("Field 1")); 722 SeleneseTestBase.assertTrue(pageSource.contains("Field 2")); 723 SeleneseTestBase.assertTrue(pageSource.contains("Field 3")); 724 SeleneseTestBase.assertTrue(pageSource.contains("Field 4")); 725 SeleneseTestBase.assertTrue(pageSource.contains("Actions")); 726 } 727 728 protected void assertTextPresent(String text) { 729 assertTextPresent(text, ""); 730 } 731 732 protected void assertTextPresent(String text, String message) { 733 String pageSource = driver.getPageSource(); 734 if (!pageSource.contains(text)) { 735 failableFail(text + " not present " + message); 736 } 737 } 738 739 protected void assertTextPresent(String text, String cssSelector, String message){ 740 WebElement element = driver.findElement(By.cssSelector(cssSelector)); 741 if (!element.getText().contains(text)){ 742 failableFail(text + " for " + cssSelector + " not present " + message); 743 } 744 } 745 746 /** 747 * Asset that the given text does not occur in the page 748 * @param text the text to search for 749 */ 750 protected void assertTextNotPresent(String text) { 751 assertTextNotPresent(text, ""); 752 } 753 754 /** 755 * Assert that the given text does not occur in the page, and add an additional message to the failure 756 * @param text the text to search for 757 * @param message the message to add to the failure 758 */ 759 protected void assertTextNotPresent(String text, String message) { 760 if (driver.getPageSource().contains(text)) { 761 failableFail(text + " not present " + message); 762 } 763 } 764 765 protected void back() { 766 driver.navigate().back(); 767 } 768 769 private void blanketApproveAssert() throws InterruptedException { 770 checkForDocError(); 771 ITUtil.checkForIncidentReport(driver.getPageSource(), DOC_SEARCH_XPATH, this, "Blanket Approve failure"); 772 waitAndClickDocSearch(); 773 waitForElementsPresentByClassName("footer-copyright", "footer-copyright"); 774 SeleneseTestBase.assertEquals("Kuali Portal Index", driver.getTitle()); 775 selectFrameIframePortlet(); 776 waitAndClickSearch(); 777 } 778 779 /** 780 * Tests blanket approve action. 781 * This method is used by several different tests which perform various types of blanket approvals. 782 * Therefore, this is a candidate to remain in this base class 783 * 784 * @throws InterruptedException 785 */ 786 protected void blanketApproveTest() throws InterruptedException { 787 ITUtil.checkForIncidentReport(driver.getPageSource(), BLANKET_APPROVE_NAME, this, ""); 788 waitAndClickByName(BLANKET_APPROVE_NAME, 789 "No blanket approve button does the user " + getUserName() + " have permission?"); 790 Thread.sleep(2000); 791 792 blanketApproveAssert(); 793 } 794 795 protected void check(By by) throws InterruptedException { 796 WebElement element = driver.findElement(by); 797 798 if (!element.isSelected()) { 799 element.click(); 800 } 801 } 802 803 protected void checkById(String id) throws InterruptedException { 804 check(By.id(id)); 805 } 806 807 protected void checkByName(String name) throws InterruptedException { 808 check(By.name(name)); 809 } 810 811 protected void checkByXpath(String locator) throws InterruptedException { 812 check(By.xpath(locator)); 813 } 814 815 protected void checkErrorMessageItem(String message) { 816 final String error_locator = "//li[@class='uif-errorMessageItem']"; 817 assertElementPresentByXpath(error_locator); 818 String errorText = null; 819 820 try { 821 errorText = getTextByXpath(error_locator); 822 } catch (InterruptedException e) { 823 e.printStackTrace(); 824 } 825 826 if (errorText != null && errorText.contains("errors")) { 827 failableFail(errorText + message); 828 } 829 } 830 831 /** 832 * Uses Selenium's findElements method which does not throw a test exception if not found. 833 */ 834 public void checkForDocError() { 835 checkForIncidentReport(); 836 if (hasDocError()) { 837 String errorText = driver.findElement(By.xpath(ITUtil.DIV_ERROR_LOCATOR)).getText(); 838 errorText = ITUtil.blanketApprovalCleanUpErrorText(errorText); 839 if (driver.findElements(By.xpath(ITUtil.DIV_EXCOL_LOCATOR)).size() > 0) { // not present if errors are at the bottom of the page (see left-errmsg below) 840 errorText = ITUtil.blanketApprovalCleanUpErrorText(driver.findElement( 841 By.xpath(ITUtil.DIV_EXCOL_LOCATOR)).getText()); // replacing errorText as DIV_EXCOL_LOCATOR includes the error count 842 } 843 if (driver.findElements(By.xpath(DIV_LEFT_ERRMSG)).size() > 0) { 844 errorText = errorText + ITUtil.blanketApprovalCleanUpErrorText(driver.findElement(By.xpath(DIV_LEFT_ERRMSG)).getText()); 845 } 846 failableFail(errorText); 847 } 848 } 849 850 /** 851 * Uses Selenium's findElements method which does not throw a test exception if not found. 852 * @return 853 */ 854 public boolean hasDocError() { 855 if (driver.findElements(By.xpath(ITUtil.DIV_ERROR_LOCATOR)).size() > 0) { 856 String errorText = driver.findElement(By.xpath(ITUtil.DIV_ERROR_LOCATOR)).getText(); 857 if (errorText != null && errorText.contains("error(s) found on page.")) { 858 return true; 859 } 860 } 861 return false; 862 } 863 864 /** 865 * Uses Selenium's findElements method which does not throw a test exception if not found. 866 * @param errorTextToMatch 867 * @return 868 */ 869 public boolean hasDocError(String errorTextToMatch) { 870 if (driver.findElements(By.xpath(ITUtil.DIV_ERROR_LOCATOR)).size() > 0) { 871 // TODO need to get the next div downs test to get the actual error text like in checkForDocError() 872 String errorText = driver.findElement(By.xpath(ITUtil.DIV_ERROR_LOCATOR)).getText(); 873 if (errorText != null && errorText.contains("error(s) found on page.")) { 874 return errorText.contains(errorTextToMatch); 875 } 876 } 877 return false; 878 } 879 880 protected void checkForIncidentReport() { 881 checkForIncidentReport("", ""); 882 } 883 884 protected void checkForIncidentReport(String locator) { 885 checkForIncidentReport(locator, ""); 886 } 887 888 protected void checkForIncidentReport(String locator, String message) { 889 ITUtil.checkForIncidentReport(driver.getPageSource(), locator, this, message); 890 } 891 892 protected void checkForIncidentReport(String locator, Failable failable, String message) { 893 ITUtil.checkForIncidentReport(driver.getPageSource(), locator, failable, message); 894 } 895 896 protected void clearText(By by) throws InterruptedException { 897 driver.findElement(by).clear(); 898 } 899 900 protected void clearText(String selector) throws InterruptedException { 901 clearText(By.cssSelector(selector)); 902 } 903 904 protected void clearTextByName(String name) throws InterruptedException { 905 clearText(By.name(name)); 906 } 907 908 protected void clearTextByXpath(String locator) throws InterruptedException { 909 clearText(By.xpath(locator)); 910 } 911 912 protected void close() { 913 driver.close(); 914 } 915 916 protected void colapseExpandByXpath(String clickLocator, String visibleLocator) throws InterruptedException { 917 waitAndClickByXpath(clickLocator); 918 waitNotVisibleByXpath(visibleLocator); 919 waitAndClickByXpath(clickLocator); 920 waitIsVisibleByXpath(visibleLocator); 921 } 922 923 protected String configNameSpaceBlanketApprove() throws Exception { 924 String docId = waitForDocId(); 925 String dtsPlusTwoChars = ITUtil.createUniqueDtsPlusTwoRandomChars(); 926 waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Validation Test Namespace " + ITUtil.createUniqueDtsPlusTwoRandomCharsNot9Digits()); 927 assertBlanketApproveButtonsPresent(); 928 waitAndTypeByXpath(DOC_CODE_XPATH, "VTN" + dtsPlusTwoChars); 929 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", 930 "Validation Test NameSpace " + dtsPlusTwoChars); 931 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.applicationId']", "RICE"); 932 933 return docId; 934 } 935 936 protected void contextLookupAssertions() throws Exception { 937 testLookUp(); 938 assertTextPresent("Notes and Attachments"); 939 waitAndClick(By.xpath(CANCEL2_XPATH)); 940 passed(); 941 } 942 943 // protected void deleteSubCollectionLine() throws Exception { 944 // // click on collections page link 945 // waitAndClickByLinkText(COLLECTIONS_LINK_TEXT); 946 // Thread.sleep(5000); 947 // 948 // // wait for collections page to load by checking the presence of a sub collection line item 949 // waitForElementPresentByName("list4[0].subList[0].field1"); 950 // 951 // // change a value in the line to be deleted 952 // waitAndTypeByName("list4[0].subList[0].field1", "selenium"); 953 // 954 // // click the delete button 955 // waitAndClickByXpath("//div[@id='collection4_disclosureContent']/div[@class='uif-stackedCollectionLayout']/div[@class='uif-group uif-gridGroup uif-collectionItem uif-gridCollectionItem']/table/tbody/tr[5]/td/div/fieldset/div/div[@class='uif-disclosureContent']/div[@class='dataTables_wrapper']/table/tbody/tr[2]/td[6]/div/fieldset/div/div[@class='uif-boxLayout uif-horizontalBoxLayout clearfix']/button"); 956 // Thread.sleep(2000); 957 // 958 // // confirm that the input box containing the modified value is not present 959 // for (int second = 0;; second++) { 960 // if (second >= waitSeconds) 961 // failableFail(TIMEOUT_MESSAGE); 962 // try { 963 // if (!"selenium".equals(getAttributeByName("list4[0].subList[0].field1", "value"))) 964 // break; 965 // } catch (Exception e) {} 966 // Thread.sleep(1000); 967 // } 968 // 969 // // verify that the value has changed for the input box in the line that has replaced the deleted one 970 // assertNotSame("selenium", getAttributeByName("list4[0].subList[0].field1", "value")); 971 // } 972 973 protected void expandColapseByXpath(String clickLocator, String visibleLocator) throws InterruptedException { 974 waitAndClickByXpath(clickLocator); 975 waitIsVisibleByXpath(visibleLocator); 976 waitAndClickByXpath(clickLocator); 977 waitNotVisibleByXpath(visibleLocator); 978 } 979 980 981 /** 982 * {@link org.openqa.selenium.WebDriver#getWindowHandles()} 983 * @return 984 */ 985 public String[] getAllWindowTitles() { 986 return (String[]) driver.getWindowHandles().toArray(); 987 } 988 989 protected String getAttribute(By by, String attribute) throws InterruptedException { 990 jiraAwareWaitFor(by, ""); 991 992 return driver.findElement(by).getAttribute(attribute); 993 } 994 995 /** 996 * Get value of any attribute by using element name 997 * 998 * @param name name of an element 999 * @param attribute the name of an attribute whose value is to be retrieved 1000 */ 1001 protected String getAttributeByName(String name, String attribute) throws InterruptedException { 1002 return getAttribute(By.name(name), attribute); 1003 } 1004 1005 /** 1006 * Get value of any attribute by using element xpath 1007 * 1008 * @param locator locating mechanism of an element 1009 * @param attribute the name of an attribute whose value is to be retrieved 1010 */ 1011 protected String getAttributeByXpath(String locator, String attribute) throws InterruptedException { 1012 return getAttribute(By.xpath(locator), attribute); 1013 } 1014 1015 protected String getBaseUrlString() { 1016 return ITUtil.getBaseUrlString(); 1017 } 1018 1019 protected int getCssCount(String selector) { 1020 return getCssCount(By.cssSelector(selector)); 1021 } 1022 1023 /** 1024 * Uses Selenium's findElements method which does not throw a test exception if not found. 1025 * @param by 1026 * @return 1027 */ 1028 protected int getCssCount(By by) { 1029 return (driver.findElements(by)).size(); 1030 } 1031 1032 protected String getDocStatus() { 1033 return driver.findElement(By.xpath(DOC_STATUS_XPATH_2)).getText(); 1034 } 1035 1036 /** 1037 * Uses Selenium's findElements method which does not throw a test exception if not found. 1038 * @param by 1039 * @return 1040 * @throws InterruptedException 1041 */ 1042 protected String[] getSelectOptions(By by) throws InterruptedException { 1043 WebElement select1 = driver.findElement(by); 1044 List<WebElement> options = select1.findElements(By.tagName("option")); 1045 String[] optionValues = new String[options.size()]; 1046 int counter = 0; 1047 1048 for (WebElement option : options) { 1049 optionValues[counter] = option.getAttribute("value"); 1050 counter++; 1051 } 1052 1053 return optionValues; 1054 } 1055 1056 protected String[] getSelectOptionsByName(String name) throws InterruptedException { 1057 return getSelectOptions(By.name(name)); 1058 } 1059 1060 protected String[] getSelectOptionsByXpath(String locator) throws InterruptedException { 1061 return getSelectOptions(By.xpath(locator)); 1062 } 1063 1064 /** 1065 * 1066 * @return sessionId 1067 */ 1068 public String getSessionId() { 1069 return sessionId; 1070 } 1071 1072 protected String getText(By by) throws InterruptedException { 1073 return driver.findElement(by).getText(); 1074 } 1075 1076 protected String getTextByClassName(String className) throws InterruptedException { 1077 return getText(By.className(className)); 1078 } 1079 1080 protected String getTextById(String id) throws InterruptedException { 1081 return getText(By.id(id)); 1082 } 1083 1084 protected String getTextByName(String name) throws InterruptedException { 1085 return getText(By.name(name)); 1086 } 1087 1088 protected String getText(String locator) throws InterruptedException { 1089 return getText(By.cssSelector(locator)); 1090 } 1091 1092 protected String getTextByXpath(String locator) throws InterruptedException { 1093 return getText(By.xpath(locator)); 1094 } 1095 1096 protected String getTitle() { 1097 return driver.getTitle(); 1098 } 1099 1100 /** 1101 * "admin" by default. Can be overridden using {@link WebDriverLegacyITBase#REMOTE_PUBLIC_USER_PROPERTY} 1102 * @return string 1103 */ 1104 public String getUserName() { 1105 return user; 1106 } 1107 1108 /** 1109 * Handles simple nested frame content; validates that a frame and nested frame exists before 1110 * switching to it 1111 * Uses Selenium's findElements method which does not throw a test exception if not found. 1112 */ 1113 protected void gotoNestedFrame() { 1114 driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS); 1115 driver.switchTo().defaultContent(); 1116 1117 if (driver.findElements(By.xpath("//iframe")).size() > 0) { 1118 WebElement containerFrame = driver.findElement(By.xpath("//iframe")); 1119 driver.switchTo().frame(containerFrame); 1120 } 1121 1122 if (driver.findElements(By.xpath("//iframe")).size() > 0) { 1123 WebElement contentFrame = driver.findElement(By.xpath("//iframe")); 1124 driver.switchTo().frame(contentFrame); 1125 } 1126 1127 driver.manage().timeouts().implicitlyWait(waitSeconds, TimeUnit.SECONDS); 1128 } 1129 1130 /** 1131 * Fail using the Failable fail method. Calls jGrowlSticky then fail. 1132 * @param message to display with failure 1133 */ 1134 public void failableFail(String message) { 1135 passed = false; 1136 jGrowlSticky(message); 1137 fail(message); // Failable.fail 1138 } 1139 1140 protected List<WebElement> findVisibleElements(By by) { 1141 List<WebElement> webElements = driver.findElements(by); 1142 List<WebElement> visibleWebElements = new LinkedList<WebElement>(); 1143 for (WebElement webElement: webElements) { 1144 if (webElement.isDisplayed()) { 1145 visibleWebElements.add(webElement); 1146 } 1147 } 1148 1149 return visibleWebElements; 1150 } 1151 1152 protected void fireEvent(String name, String event) { 1153 ((JavascriptExecutor) driver).executeScript("var elements=document.getElementsByName(\"" + name + "\");" + 1154 "for (var i = 0; i < elements.length; i++){" + 1155 "elements[i]." + event + "();}"); 1156 } 1157 1158 protected void fireEvent(String name, String value, String event) { 1159 ((JavascriptExecutor) driver).executeScript("var elements=document.getElementsByName(\"" + name + "\");" + 1160 "for (var i = 0; i < elements.length; i++){" + 1161 "if(elements[i].value=='" + value + "')" + 1162 "elements[i]." + event + "();}"); 1163 } 1164 1165 /** 1166 * {@link Actions#moveToElement(org.openqa.selenium.WebElement)} 1167 * @param name 1168 */ 1169 public void fireMouseOverEventByName(String name) { 1170 this.fireMouseOverEvent(By.name(name)); 1171 } 1172 1173 /** 1174 * {@link Actions#moveToElement(org.openqa.selenium.WebElement)} 1175 * @param locator 1176 */ 1177 public void fireMouseOverEventByXpath(String locator) { 1178 this.fireMouseOverEvent(By.xpath(locator)); 1179 } 1180 1181 /** 1182 * {@link Actions#moveToElement(org.openqa.selenium.WebElement)} 1183 * @param by 1184 */ 1185 public void fireMouseOverEvent(By by) { 1186 Actions builder = new Actions(driver); 1187 Actions hover = builder.moveToElement(driver.findElement(by)); 1188 hover.perform(); 1189 } 1190 1191 protected boolean isChecked(By by) { 1192 return driver.findElement(by).isSelected(); 1193 } 1194 1195 protected boolean isCheckedById(String id) { 1196 return isChecked(By.id(id)); 1197 } 1198 1199 protected boolean isCheckedByName(String name) { 1200 return isChecked(By.name(name)); 1201 } 1202 1203 protected boolean isCheckedByXpath(String locator) { 1204 return isChecked(By.xpath(locator)); 1205 } 1206 1207 protected boolean isEnabled(By by) { 1208 return driver.findElement(by).isEnabled(); 1209 } 1210 1211 protected boolean isEnabledById(String id) { 1212 return isEnabled(By.id(id)); 1213 } 1214 1215 protected boolean isEnabledByName(String name) { 1216 return isEnabled(By.name(name)); 1217 } 1218 1219 protected boolean isEnabledByXpath(String locator) { 1220 return isEnabled(By.xpath(locator)); 1221 } 1222 1223 protected int howManyAreVisible(By by) throws InterruptedException { 1224 int count = 0; 1225 if (by == null) { 1226 1227 return count; 1228 } 1229 1230 List<WebElement> webElementsFound = driver.findElements(by); 1231 for (WebElement webElement: webElementsFound) { 1232 if (webElement.isDisplayed()) { 1233 count++; 1234 } 1235 } 1236 1237 return count; 1238 } 1239 1240 /** 1241 * Uses Selenium's findElements method which does not throw a test exception if not found. 1242 * @param by 1243 * @return 1244 */ 1245 protected boolean isElementPresent(By by) { 1246 return (driver.findElements(by)).size() > 0; 1247 } 1248 1249 /** 1250 * Uses Selenium's findElements method which does not throw a test exception if not found. 1251 * @param locator 1252 * @return 1253 */ 1254 protected boolean isElementPresent(String locator) { 1255 return (driver.findElements(By.cssSelector(locator))).size() > 0; 1256 } 1257 1258 protected boolean isElementPresentById(String id) { 1259 return isElementPresent(By.id(id)); 1260 } 1261 1262 protected boolean isElementPresentByName(String name) { 1263 return isElementPresent(By.name(name)); 1264 } 1265 1266 protected boolean isElementPresentByXpath(String locator) { 1267 return isElementPresent(By.xpath(locator)); 1268 } 1269 1270 protected boolean isElementPresentByLinkText(String locator) { 1271 return isElementPresent(By.linkText(locator)); 1272 } 1273 1274 protected boolean isElementPresentByDataAttributeValue(String dataAttributeName, String dataAttributeValue) { 1275 return isElementPresent(By.cssSelector("[data-" + dataAttributeName +"='"+ dataAttributeValue +"']")); 1276 } 1277 1278 protected Boolean isTextPresent(String text) { 1279 if (driver.getPageSource().contains(text)) { 1280 return Boolean.TRUE; 1281 } 1282 1283 return Boolean.FALSE; 1284 } 1285 1286 protected boolean isVisible(String locator) { 1287 return isVisible(By.cssSelector(locator)); 1288 } 1289 1290 protected boolean isVisible(By by) { 1291 List<WebElement> elements = driver.findElements(by); 1292 for (WebElement element: elements) { 1293 if (element.isDisplayed()) { 1294 return true; 1295 } 1296 } 1297 return false; 1298 } 1299 1300 protected boolean isVisibleById(String id) { 1301 return isVisible(By.id(id)); 1302 } 1303 1304 protected boolean isVisibleByXpath(String locator) { 1305 return isVisible(By.xpath(locator)); 1306 } 1307 1308 protected void jGrowl(String message) { 1309 WebDriverUtil.jGrowl(driver, jGrowlHeader, false, message); 1310 } 1311 1312 /** 1313 * Sticky is used on fail, making a call to jGrowl(String) from this method will result 1314 * in an infinite loop if JGROWL_ERROR_FAILURE is true so please don't. 1315 */ 1316 protected void jGrowlSticky(String message) { 1317 WebDriverUtil.jGrowl(driver, jGrowlHeader, true, message); 1318 } 1319 1320 private void jiraAwareFail(By by, String message, Throwable t) { 1321 JiraAwareFailureUtil.failOnMatchedJira(by.toString(), message, this); 1322 // if there isn't a matched jira to fail on, then fail 1323 checkForIncidentReport(by.toString(), message); 1324 failableFail(t.getMessage() + " " + by.toString() + " " + message + " " + driver.getCurrentUrl()); 1325 } 1326 1327 private void jiraAwareFail(String message) { 1328 JiraAwareFailureUtil.failOnMatchedJira(message, message, this); 1329 // if there isn't a matched jira to fail on, then fail 1330 checkForIncidentReport(message, message); 1331 failableFail(message + " " + driver.getCurrentUrl()); 1332 } 1333 1334 protected void jiraAwareWaitAndClick(By by, String message) throws InterruptedException { 1335 jiraAwareWaitAndClick(by, message, this); 1336 } 1337 1338 protected void jiraAwareWaitAndClick(By by, String message, Failable failable) throws InterruptedException { 1339 try { 1340 jiraAwareWaitFor(by, message, failable); 1341 WebElement element = driver.findElement(by); 1342 WebDriverUtil.highlightElement(driver, element); 1343 element.click(); 1344 } catch (Exception e) { 1345 jiraAwareFail(by, message, e); 1346 } 1347 } 1348 1349 protected void jiraAwareWaitFor(By by, String message) throws InterruptedException { 1350 try { 1351 WebDriverUtil.waitFor(this.driver, this.waitSeconds, by, message); 1352 } catch (Throwable t) { 1353 jiraAwareFail(by, message, t); 1354 } 1355 } 1356 1357 protected void jiraAwareWaitFors(By by, String message) throws InterruptedException { 1358 try { 1359 WebDriverUtil.waitFors(this.driver, this.waitSeconds, by, message); 1360 } catch (Throwable t) { 1361 jiraAwareFail(by, message, t); 1362 } 1363 } 1364 1365 protected void jiraAwareWaitFor(By by, String message, Failable failable) throws InterruptedException { 1366 try { 1367 WebDriverUtil.waitFor(this.driver, this.waitSeconds, by, message); 1368 } catch (Throwable t) { 1369 jiraAwareFail(by, message, t); 1370 } 1371 } 1372 1373 protected void open(String url) { 1374 driver.get(url); 1375 } 1376 1377 protected void selectFrameIframePortlet() { 1378 selectFrame(IFRAMEPORTLET_NAME); 1379 } 1380 1381 protected void selectFrame(String locator) { 1382 1383 if (IFRAMEPORTLET_NAME.equals(locator)) { 1384 gotoNestedFrame(); 1385 } else { 1386 WebDriverUtil.selectFrameSafe(driver, locator); 1387 } 1388 } 1389 1390 protected void selectTopFrame() { 1391 driver.switchTo().defaultContent(); 1392 } 1393 1394 protected void selectWindow(String locator) { 1395 driver.switchTo().window(locator); 1396 } 1397 1398 protected void selectByXpath(String locator, String selectText) throws InterruptedException { 1399 select(By.xpath(locator), selectText); 1400 } 1401 1402 protected void selectByName(String name, String selectText) throws InterruptedException { 1403 select(By.name(name), selectText); 1404 } 1405 1406 /** 1407 * Uses Selenium's findElements method which does not throw a test exception if not found. 1408 * @param by 1409 * @param selectText 1410 * @throws InterruptedException 1411 */ 1412 protected void select(By by, String selectText) throws InterruptedException { 1413 WebElement select1 = driver.findElement(by); 1414 List<WebElement> options = select1.findElements(By.tagName("option")); 1415 1416 for (WebElement option : options) { 1417 if (option.getText().equals(selectText)) { 1418 option.click(); 1419 break; 1420 } 1421 } 1422 } 1423 1424 protected void selectOptionByName(String name, String optionValue) throws InterruptedException { 1425 selectOption(By.name(name), optionValue); 1426 } 1427 1428 protected void selectOptionByXpath(String locator, String optionValue) throws InterruptedException { 1429 selectOption(By.name(locator), optionValue); 1430 } 1431 1432 /** 1433 * Uses Selenium's findElements method which does not throw a test exception if not found. 1434 * @param by 1435 * @param optionValue 1436 * @throws InterruptedException 1437 */ 1438 protected void selectOption(By by, String optionValue) throws InterruptedException { 1439 WebElement select1 = driver.findElement(by); 1440 List<WebElement> options = select1.findElements(By.tagName("option")); 1441 1442 if (options == null || options.size() == 0) { 1443 failableFail("No options for select " + select1.toString() + " was looking for value " + optionValue + " using " + by.toString()); 1444 } 1445 1446 for (WebElement option : options) { 1447 if (option.getAttribute("value").equals(optionValue)) { 1448 option.click(); 1449 break; 1450 } 1451 } 1452 } 1453 1454 /** 1455 * If a window contains the given title switchTo it. 1456 * @param title 1457 */ 1458 public void switchToWindow(String title) { 1459 Set<String> windows = driver.getWindowHandles(); 1460 1461 for (String window : windows) { 1462 driver.switchTo().window(window); 1463 if (driver.getTitle().contains(title)) { 1464 return; 1465 } 1466 } 1467 } 1468 1469 // TODO delete after AddingNameSpaceAbstractSmokeTestBase migration 1470 protected void testAddingNamespace() throws Exception { 1471 testAddingNamespace(this); 1472 } 1473 1474 // TODO move method to AddingNameSpaceAbstractSmokeTestBase after locators are extracted 1475 protected void testAddingNamespace(Failable failable) throws Exception { 1476 selectFrameIframePortlet(); 1477 waitAndCreateNew(); 1478 waitForPageToLoad(); 1479 assertElementPresentByXpath(SAVE_XPATH_2, "save button does not exist on the page"); 1480 1481 //Enter details for Namespace. 1482 waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Adding PEANUTS"); 1483 waitAndTypeByXpath("//*[@id='document.documentHeader.explanation']", "I want to add PEANUTS to test KIM"); 1484 waitAndTypeByXpath(DOC_CODE_XPATH, "PEANUTS"); 1485 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", "The Peanuts Gang"); 1486 checkByXpath("//input[@id='document.newMaintainableObject.active']"); 1487 waitAndClickByXpath(SAVE_XPATH_2); 1488 waitForPageToLoad(); 1489 checkForIncidentReport(); 1490 assertDocumentStatusSaved(); 1491 1492 //checks it is saved and initiator is admin. 1493 SeleneseTestBase.assertEquals(DOC_STATUS_SAVED, driver.findElement(By.xpath( 1494 "//table[@class='headerinfo']/tbody/tr[1]/td[2]")).getText()); 1495 SeleneseTestBase.assertEquals("admin", driver.findElement(By.xpath( 1496 "//table[@class='headerinfo']/tbody/tr[2]/td[1]/a")).getText()); 1497 } 1498 1499 protected void assertDocumentStatusSaved() { 1500 assertElementPresentByXpath(SAVE_SUCCESSFUL_XPATH, 1501 "Document is not saved successfully"); 1502 } 1503 1504 protected void testAddingBrownGroup() throws Exception { 1505 selectFrameIframePortlet(); 1506 waitAndCreateNew(); 1507 waitForPageToLoad(); 1508 String docId = waitForDocId(); 1509 1510 //Enter details for BrownGroup. 1511 waitAndTypeByName("document.documentHeader.documentDescription", "Adding Brown Group"); 1512 waitAndTypeByName("document.documentHeader.explanation", "I want to add Brown Group to test KIM"); 1513 selectOptionByName("document.groupNamespace", "KR-IDM"); 1514 waitForPageToLoad(); 1515 String groupName = "BrownGroup " + ITUtil.createUniqueDtsPlusTwoRandomChars(); 1516 waitAndTypeByName("document.groupName", groupName); 1517 checkByName("document.active"); 1518 waitAndClickByXpath(SAVE_XPATH_2); 1519 waitForPageToLoad(); 1520 assertElementPresentByXpath(SAVE_SUCCESSFUL_XPATH,"Document is not saved successfully"); 1521 checkForIncidentReport(); 1522 1523 //checks it is saved and initiator is admin. 1524 SeleneseTestBase.assertEquals(DOC_STATUS_SAVED, driver.findElement(By.xpath("//table[@class='headerinfo']/tbody/tr[1]/td[2]")).getText()); 1525 SeleneseTestBase.assertEquals("admin", driver.findElement(By.xpath("//table[@class='headerinfo']/tbody/tr[2]/td[1]/a")).getText()); 1526 waitAndClickByName("methodToCall.performLookup.(!!org.kuali.rice.kim.impl.identity.PersonImpl!!).(((principalId:member.memberId,principalName:member.memberName))).((``)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;;::::).anchorAssignees"); 1527 waitForPageToLoad(); 1528 waitAndClickSearch(); 1529 waitForPageToLoad(); 1530 waitAndClickReturnValue(); 1531 waitForPageToLoad(); 1532 waitAndClickByName("methodToCall.addMember.anchorAssignees"); 1533 waitForPageToLoad(); 1534 waitAndClickSave(); 1535 waitAndClickSubmit(); 1536 waitForPageToLoad(); 1537 assertElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH,"Document is not submitted successfully"); 1538 selectTopFrame(); 1539 waitAndClickByLinkText("Administration"); 1540 waitForPageToLoad(); 1541 waitAndClickByLinkText("Group"); 1542 waitForPageToLoad(); 1543 selectFrameIframePortlet(); 1544 waitAndTypeByName("name", groupName); 1545 waitAndClickSearch(); 1546 isElementPresentByLinkText(groupName); 1547 } 1548 1549 protected void testAttributeDefinitionLookUp() throws Exception { 1550 waitForPageToLoad(); 1551 selectFrameIframePortlet(); 1552 checkForIncidentReport("testAttributeDefinitionLookUp"); 1553 waitAndClickByXpath("//button[contains(.,'earch')]"); 1554 Thread.sleep(3000); 1555 waitForPageToLoad(); 1556 driver.findElement(By.tagName("body")).getText().contains("Actions"); // there are no actions, but the header is the only unique text from searching 1557 waitAndClickByLinkText("1000"); 1558 waitForPageToLoad(); 1559 driver.findElement(By.tagName("body")).getText().contains("Attribute Inquiry"); 1560 driver.findElement(By.tagName("body")).getText().contains("KRMS Attributes"); 1561 driver.findElement(By.tagName("body")).getText().contains("Attribute Label"); 1562 driver.findElement(By.tagName("body")).getText().contains("1000"); 1563 driver.findElement(By.tagName("body")).getText().contains("peopleFlowId"); 1564 driver.findElement(By.tagName("body")).getText().contains("KR-RULE"); 1565 driver.findElement(By.tagName("body")).getText().contains("PeopleFlow"); 1566 1567 // selectFrame("name=fancybox-frame1343151577256"); // TODO parse source to get name 1568 // jiraAwareWaitAndClick("css=button:contains(Close)"); // looks lower case, but is upper 1569 // Thread.sleep(500); 1570 // jiraAwareWaitAndClick("css=button:contains(cancel)"); 1571 // AttributeDefinition's don't have actions (yet) 1572 // jiraAwareWaitAndClick("id=u80"); 1573 // waitForPageToLoad(); 1574 // jiraAwareWaitAndClick("id=u86"); 1575 // waitForPageToLoad(); 1576 // selectWindow("null"); 1577 // jiraAwareWaitAndClick("xpath=(//input[@name='imageField'])[2]"); 1578 // waitForPageToLoad(); 1579 passed(); 1580 } 1581 1582 protected void testCancelConfirmation() throws InterruptedException { 1583 waitAndCancelConfirmation(); 1584 passed(); 1585 } 1586 1587 protected void testConfigParamaterBlanketApprove() throws Exception { 1588 selectFrameIframePortlet(); 1589 waitAndCreateNew(); 1590 String docId = waitForDocId(); 1591 waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Validation Test Parameter "); 1592 assertBlanketApproveButtonsPresent(); 1593 SeleneseTestBase.assertEquals("", getTextByName(CANCEL_NAME)); 1594 selectByXpath("//select[@id='document.newMaintainableObject.namespaceCode']", "KR-NS - Kuali Nervous System"); 1595 String componentLookUp = "//input[@name='methodToCall.performLookup.(!!org.kuali.rice.coreservice.impl.component.ComponentBo!!).(((code:document.newMaintainableObject.componentCode,namespaceCode:document.newMaintainableObject.namespaceCode,))).((`document.newMaintainableObject.componentCode:code,document.newMaintainableObject.namespaceCode:namespaceCode,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" 1596 + getBaseUrlString() + "/kr/lookup.do;::::).anchor4']"; 1597 waitAndClickByXpath(componentLookUp); 1598 waitAndClickSearch(); 1599 waitAndClickReturnValue(); 1600 String dtsTwo = ITUtil.createUniqueDtsPlusTwoRandomChars(); 1601 String parameterName = "ValidationTestParameter" + dtsTwo; 1602 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", parameterName); 1603 waitAndTypeByXpath("//textarea[@id='document.newMaintainableObject.description']", 1604 "Validation Test Parameter Description" + dtsTwo); 1605 selectByXpath("//select[@id='document.newMaintainableObject.parameterTypeCode']", "Document Validation"); 1606 waitAndClickByXpath("//input[@id='document.newMaintainableObject.evaluationOperatorCodeAllowed']"); 1607 waitForPageToLoad(); 1608 blanketApproveTest(); 1609 assertDocFinal(docId); 1610 } 1611 1612 protected void testCreateNewAgenda() throws Exception { 1613 selectFrameIframePortlet(); 1614 selectByName("document.newMaintainableObject.dataObject.namespace", "Kuali Rules Test"); 1615 String agendaName = "Agenda Date :" + Calendar.getInstance().getTime().toString(); 1616 waitAndTypeByName("document.newMaintainableObject.dataObject.agenda.name", "Agenda " + agendaName); 1617 waitAndTypeByName("document.newMaintainableObject.dataObject.contextName", "Context1"); 1618 fireEvent("document.newMaintainableObject.dataObject.contextName", "blur"); 1619 fireEvent("document.newMaintainableObject.dataObject.contextName", "focus"); 1620 waitForElementPresentByName("document.newMaintainableObject.dataObject.agenda.typeId"); 1621 selectByName("document.newMaintainableObject.dataObject.agenda.typeId", "Campus Agenda"); 1622 waitForElementPresentByName("document.newMaintainableObject.dataObject.customAttributesMap[Campus]"); 1623 waitAndTypeByName("document.newMaintainableObject.dataObject.customAttributesMap[Campus]", "BL"); 1624 waitAndClickByXpath("//div[2]/button"); 1625 waitForPageToLoad(); 1626 waitAndClickByXpath("//div[2]/button[3]"); 1627 waitForPageToLoad(); 1628 selectTopFrame(); 1629 waitAndClickByXpath("(//input[@name='imageField'])[2]"); 1630 passed(); 1631 } 1632 1633 protected void testCreateDocType() throws Exception { 1634 selectFrameIframePortlet(); 1635 waitAndCreateNew(); 1636 assertElementPresentByXpath("//*[@name='methodToCall.route' and @alt='submit']","save button does not exist on the page"); 1637 1638 //waitForElementPresentByXpath(DOC_ID_XPATH); 1639 //String docId = driver.findElement(By.xpath(DOC_ID_XPATH)).getText(); 1640 String docId = waitForDocId(); 1641 waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Creating new Document Type"); 1642 String parentDocType = "//input[@name='methodToCall.performLookup.(!!org.kuali.rice.kew.doctype.bo.DocumentType!!).(((name:document.newMaintainableObject.parentDocType.name,documentTypeId:document.newMaintainableObject.docTypeParentId,))).((`document.newMaintainableObject.parentDocType.name:name,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" 1643 + getBaseUrlString() + "/kr/lookup.do;::::).anchor4']"; 1644 waitAndClickByXpath(parentDocType); 1645 waitForPageToLoad(); 1646 Thread.sleep(2000); 1647 waitAndClickSearch(); 1648 waitForPageToLoad(); 1649 waitAndClickReturnValue(); 1650 String docTypeName = "TestDocType" + ITUtil.createUniqueDtsPlusTwoRandomChars(); 1651 waitForElementPresentByXpath("//input[@id='document.newMaintainableObject.name']"); 1652 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", docTypeName); 1653 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.unresolvedDocHandlerUrl']","${kr.url}/maintenance.do?methodToCall=docHandler"); 1654 1655 //waitAndTypeByXpath("//input[@id='document.newMaintainableObject.actualNotificationFromAddress']", "NFA"); 1656 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.label']", "TestDocument Label"); 1657 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.unresolvedHelpDefinitionUrl']","default.htm?turl=WordDocuments%2Fdocumenttype.htm"); 1658 waitAndClickByXpath("//*[@name='methodToCall.route' and @alt='submit']"); 1659 checkForIncidentReport(); 1660 waitForPageToLoad(); 1661 driver.switchTo().defaultContent(); 1662 waitAndClickDocSearchTitle(); 1663 waitForPageToLoad(); 1664 selectFrameIframePortlet(); 1665 waitAndClickSearch(); 1666 Thread.sleep(2000); 1667 SeleneseTestBase.assertEquals(docId, driver.findElement(By.xpath(DOC_ID_XPATH_2)).getText()); 1668 } 1669 1670 protected void testCreateNewCancel() throws Exception { 1671 selectFrameIframePortlet(); 1672 waitAndCreateNew(); 1673 testCancelConfirmation(); 1674 } 1675 1676 protected List<String> testCreateNewParameter(String docId, String parameterName) throws Exception { 1677 waitForPageToLoad(); 1678 docId = waitForDocId(); 1679 //Enter details for Parameter. 1680 waitAndTypeByName("document.documentHeader.documentDescription", "Adding Test Parameter"); 1681 selectOptionByName("document.newMaintainableObject.namespaceCode", "KR-WKFLW"); 1682 waitAndTypeByName("document.newMaintainableObject.componentCode", "ActionList"); 1683 waitAndTypeByName("document.newMaintainableObject.applicationId", "KUALI"); 1684 parameterName = "TestIndicator" + ITUtil.createUniqueDtsPlusTwoRandomChars(); 1685 waitAndTypeByName("document.newMaintainableObject.name", parameterName); 1686 waitAndTypeByName("document.newMaintainableObject.value", "Y"); 1687 waitAndTypeByName("document.newMaintainableObject.description", "for testing"); 1688 selectOptionByName("document.newMaintainableObject.parameterTypeCode", "HELP"); 1689 waitAndClickByXpath("//input[@name='document.newMaintainableObject.evaluationOperatorCode' and @value='A']"); 1690 waitAndClickSave(); 1691 waitAndClickSubmit(); 1692 waitForPageToLoad(); 1693 assertElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH,"Document is not submitted successfully"); 1694 selectTopFrame(); 1695 waitAndClickDocSearchTitle(); 1696 waitForPageToLoad(); 1697 selectFrameIframePortlet(); 1698 waitAndClickSearch(); 1699 Thread.sleep(2000); 1700 SeleneseTestBase.assertEquals(docId, getTextByXpath(DOC_ID_XPATH_3)); 1701 SeleneseTestBase.assertEquals(DOC_STATUS_FINAL, getTextByXpath(DOC_STATUS_XPATH_2)); 1702 selectTopFrame(); 1703 List<String> params = new ArrayList<String>(); 1704 params.add(docId); 1705 params.add(parameterName); 1706 1707 return params; 1708 } 1709 1710 protected List<String> testCreateNewParameterType(String docId, String parameterType, String parameterCode)throws Exception { 1711 waitForPageToLoad(); 1712 docId = waitForDocId(); 1713 1714 //Enter details for Parameter. 1715 waitAndTypeByName("document.documentHeader.documentDescription", "Adding Test Parameter Type"); 1716 parameterCode = RandomStringUtils.randomAlphabetic(4).toLowerCase(); 1717 waitAndTypeByName("document.newMaintainableObject.code", parameterCode); 1718 parameterType = "testing " + ITUtil.createUniqueDtsPlusTwoRandomChars(); 1719 waitAndTypeByName("document.newMaintainableObject.name", parameterType); 1720 waitAndClickSave(); 1721 waitAndClickSubmit(); 1722 waitForPageToLoad(); 1723 assertElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH, "Document is not submitted successfully"); 1724 selectTopFrame(); 1725 waitAndClickDocSearchTitle(); 1726 waitForPageToLoad(); 1727 selectFrameIframePortlet(); 1728 waitAndClickSearch(); 1729 Thread.sleep(2000); 1730 SeleneseTestBase.assertEquals(docId, getTextByXpath(DOC_ID_XPATH_3)); 1731 SeleneseTestBase.assertEquals(DOC_STATUS_FINAL, getTextByXpath(DOC_STATUS_XPATH_2)); 1732 selectTopFrame(); 1733 List<String> params = new ArrayList<String>(); 1734 params.add(docId); 1735 params.add(parameterType); 1736 params.add(parameterCode); 1737 1738 return params; 1739 } 1740 1741 protected void testCreateNewSearchReturnValueCancelConfirmation() throws InterruptedException, Exception { 1742 selectFrameIframePortlet(); 1743 waitAndCreateNew(); 1744 waitAndClickSearch2(); 1745 waitAndClickReturnValue(); 1746 waitAndCancelConfirmation(); 1747 passed(); 1748 } 1749 1750 protected List<String> testCopyParameter(String docId, String parameterName) throws Exception { 1751 selectFrameIframePortlet(); 1752 waitAndClickCopy(); 1753 waitForPageToLoad(); 1754 docId = waitForDocId(); 1755 waitAndTypeByName("document.documentHeader.documentDescription", "Copying Test Parameter"); 1756 selectOptionByName("document.newMaintainableObject.namespaceCode", "KR-WKFLW"); 1757 waitAndTypeByName("document.newMaintainableObject.componentCode", "ActionList"); 1758 waitAndTypeByName("document.newMaintainableObject.applicationId", "KUALI"); 1759 parameterName = "TestIndicator" + ITUtil.createUniqueDtsPlusTwoRandomChars(); 1760 waitAndTypeByName("document.newMaintainableObject.name", parameterName); 1761 waitAndClickSave(); 1762 waitAndClickSubmit(); 1763 waitForPageToLoad(); 1764 assertElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH,"Document is not submitted successfully"); 1765 selectTopFrame(); 1766 waitAndClickDocSearchTitle(); 1767 waitForPageToLoad(); 1768 selectFrameIframePortlet(); 1769 waitAndClickSearch(); 1770 Thread.sleep(2000); 1771 SeleneseTestBase.assertEquals(docId, getTextByXpath(DOC_ID_XPATH_3)); 1772 SeleneseTestBase.assertEquals(DOC_STATUS_FINAL, getTextByXpath(DOC_STATUS_XPATH_2)); 1773 selectTopFrame(); 1774 List<String> params = new ArrayList<String>(); 1775 params.add(docId); 1776 params.add(parameterName); 1777 1778 return params; 1779 } 1780 1781 protected List<String> testCopyParameterType(String docId, String parameterType, String parameterCode) throws Exception { 1782 selectFrameIframePortlet(); 1783 waitAndClickCopy(); 1784 waitForPageToLoad(); 1785 docId = waitForDocId(); 1786 waitAndTypeByName("document.documentHeader.documentDescription", "Copying Test Parameter"); 1787 parameterCode = RandomStringUtils.randomAlphabetic(4).toLowerCase(); 1788 waitAndTypeByName("document.newMaintainableObject.code", parameterCode); 1789 clearTextByName("document.newMaintainableObject.name"); 1790 parameterType = "testing " + ITUtil.createUniqueDtsPlusTwoRandomChars(); 1791 waitAndTypeByName("document.newMaintainableObject.name", parameterType); 1792 waitAndClickSave(); 1793 waitAndClickSubmit(); 1794 waitForPageToLoad(); 1795 assertElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH, "Document is not submitted successfully"); 1796 selectTopFrame(); 1797 waitAndClickDocSearchTitle(); 1798 waitForPageToLoad(); 1799 selectFrameIframePortlet(); 1800 waitAndClickSearch(); 1801 Thread.sleep(2000); 1802 SeleneseTestBase.assertEquals(docId, getTextByXpath(DOC_ID_XPATH_3)); 1803 SeleneseTestBase.assertEquals(DOC_STATUS_FINAL, getTextByXpath(DOC_STATUS_XPATH_2)); 1804 selectTopFrame(); 1805 List<String> params = new ArrayList<String>(); 1806 params.add(docId); 1807 params.add(parameterType); 1808 params.add(parameterCode); 1809 1810 return params; 1811 } 1812 1813 1814 protected void testDocTypeLookup() throws Exception { 1815 selectFrameIframePortlet(); 1816 waitAndClickByXpath("//input[@title='Search Parent Name']"); 1817 waitForPageToLoad(); 1818 waitAndClickByXpath(SAVE_XPATH_3); 1819 waitAndClickByXpath("//table[@id='row']/tbody/tr[contains(td[3],'RiceDocument')]/td[1]/a"); 1820 waitForPageToLoad(); 1821 waitAndClickByXpath(SAVE_XPATH_3); 1822 SeleneseTestBase.assertEquals("RiceDocument", getTextByXpath("//table[@id='row']/tbody/tr/td[4]/a")); 1823 waitAndClickByName("methodToCall.clearValues"); 1824 waitAndTypeByName("name", "Kuali*D"); 1825 waitAndClickByXpath(SAVE_XPATH_3); 1826 assertElementPresentByXpath("//table[@id='row']/tbody/tr[contains(td[3], 'KualiDocument')]"); 1827 String docIdOld = getTextByXpath("//table[@id='row']/tbody/tr[contains(td[3], 'KualiDocument')]/td[2]/a"); 1828 waitAndClickByName("methodToCall.clearValues"); 1829 waitAndTypeByName("label", "KualiDocument"); 1830 waitAndClickByXpath(SAVE_XPATH_3); 1831 assertElementPresentByXpath("//table[@id='row']/tbody/tr[contains(td[5], 'KualiDocument')]"); 1832 waitAndClickByName("methodToCall.clearValues"); 1833 waitAndTypeByName("documentTypeId", docIdOld); 1834 waitAndClickByXpath(SAVE_XPATH_3); 1835 assertElementPresentByXpath("//table[@id='row']/tbody/tr[contains(td[2], '" + docIdOld + "')]"); 1836 } 1837 1838 1839 protected List<String> testEditParameterType(String docId, String parameterType, String parameterCode) throws Exception { 1840 selectFrameIframePortlet(); 1841 waitAndClickEdit(); 1842 waitForPageToLoad(); 1843 docId = waitForDocId(); 1844 waitAndTypeByName("document.documentHeader.documentDescription", "Editing Test Parameter"); 1845 clearTextByName("document.newMaintainableObject.name"); 1846 parameterType = "testing " + ITUtil.createUniqueDtsPlusTwoRandomChars(); 1847 waitAndTypeByName("document.newMaintainableObject.name", parameterType); 1848 waitAndClickSave(); 1849 waitAndClickSubmit(); 1850 waitForPageToLoad(); 1851 assertElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH, "Document is not submitted successfully"); 1852 selectTopFrame(); 1853 waitAndClickDocSearchTitle(); 1854 waitForPageToLoad(); 1855 selectFrameIframePortlet(); 1856 waitAndClickSearch(); 1857 Thread.sleep(2000); 1858 SeleneseTestBase.assertEquals(docId, getTextByXpath(DOC_ID_XPATH_3)); 1859 SeleneseTestBase.assertEquals(DOC_STATUS_FINAL, getTextByXpath(DOC_STATUS_XPATH_2)); 1860 selectTopFrame(); 1861 List<String> params = new ArrayList<String>(); 1862 params.add(docId); 1863 params.add(parameterType); 1864 params.add(parameterCode); 1865 1866 return params; 1867 } 1868 1869 protected List<String> testEditParameter(String docId, String parameterName) throws Exception 1870 { 1871 selectFrameIframePortlet(); 1872 waitAndClickEdit(); 1873 waitForPageToLoad(); 1874 docId = waitForDocId(); 1875 waitAndTypeByName("document.documentHeader.documentDescription", "Editing Test Parameter"); 1876 clearTextByName("document.newMaintainableObject.value"); 1877 waitAndTypeByName("document.newMaintainableObject.value", "N"); 1878 waitAndClickSave(); 1879 waitAndClickSubmit(); 1880 waitForPageToLoad(); 1881 assertElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH, "Document is not submitted successfully"); 1882 selectTopFrame(); 1883 waitAndClickDocSearchTitle(); 1884 waitForPageToLoad(); 1885 selectFrameIframePortlet(); 1886 waitAndClickSearch(); 1887 Thread.sleep(2000); 1888 SeleneseTestBase.assertEquals(docId, getTextByXpath(DOC_ID_XPATH_3)); 1889 SeleneseTestBase.assertEquals(DOC_STATUS_FINAL, getTextByXpath(DOC_STATUS_XPATH_2)); 1890 selectTopFrame(); 1891 List<String> params = new ArrayList<String>(); 1892 params.add(docId); 1893 params.add(parameterName); 1894 return params; 1895 } 1896 1897 protected void testEditRouteRulesDelegation() throws Exception { 1898 waitForPageToLoad(); 1899 Thread.sleep(3000); 1900 SeleneseTestBase.assertEquals("Kuali Portal Index", getTitle()); 1901 selectFrameIframePortlet(); 1902 waitAndClickSearch(); 1903 waitForPageToLoad(); 1904 Thread.sleep(3000); 1905 waitAndClickEdit(); 1906 waitForPageToLoad(); 1907 Thread.sleep(3000); 1908 SeleneseTestBase.assertTrue(isElementPresentByName(CANCEL_NAME)); 1909 waitAndClickCancel(); 1910 waitForPageToLoad(); 1911 Thread.sleep(3000); 1912 waitAndClickByName("methodToCall.processAnswer.button0"); 1913 waitForPageToLoad(); 1914 passed(); 1915 } 1916 1917 protected void testFiscalOfficerInfoMaintenanceNew() throws Exception { 1918 selectFrameIframePortlet(); 1919 checkForIncidentReport("", "https://jira.kuali.org/browse/KULRICE-7723 FiscalOfficerInfoMaintenanceNewIT.testUntitled need a better name and user permission error"); 1920 String docId = getTextByXpath("//*[@id='u13_control']"); 1921 waitAndTypeByXpath("//input[@name='document.documentHeader.documentDescription']", "New FO Doc"); 1922 waitAndTypeByXpath("//input[@name='document.newMaintainableObject.dataObject.id']", "5"); 1923 waitAndTypeByXpath("//input[@name='document.newMaintainableObject.dataObject.userName']", "Jigar"); 1924 waitAndClickByXpath("//button[@id='usave']"); 1925 Integer docIdInt = Integer.valueOf(docId).intValue(); 1926 selectTopFrame(); 1927 waitAndClickByXpath("//img[@alt='action list']"); 1928 selectFrameIframePortlet(); 1929 1930 if(isElementPresentByLinkText("Last")){ 1931 waitAndClickByLinkText("Last"); 1932 waitAndClickByLinkText(docIdInt.toString()); 1933 } else { 1934 waitAndClickByLinkText(docIdInt.toString()); 1935 } 1936 1937 // ------------------------------- Not working in code when click docId link in list-------------------------- 1938 //Thread.sleep(5000); 1939 //String[] windowTitles = getAllWindowTitles(); 1940 //selectWindow(windowTitles[1]); 1941 //windowFocus(); 1942 //assertEquals(windowTitles[1], getTitle()); 1943 //checkForIncidentReport("Action List Id link opened window.", "https://jira.kuali.org/browse/KULRICE-9062 Action list id links result in 404 or NPE"); 1944 1945 //------submit-----// 1946 //selectFrame("relative=up"); 1947 //waitAndClick("//button[@value='submit']"); 1948 //waitForPageToLoad50000(); 1949 //close(); 1950 //------submit over---// 1951 1952 //----step 2----// 1953 //selectWindow("null"); 1954 //windowFocus(); 1955 //waitAndClick("//img[@alt='doc search']"); 1956 //waitForPageToLoad50000(); 1957 //assertEquals(windowTitles[0], getTitle()); 1958 //selectFrame("iframeportlet"); 1959 //waitAndClick(SEARCH_XPATH); 1960 //waitForPageToLoad50000(); 1961 //----step 2 over ----// 1962 1963 //-----Step 3 verifies that doc is final-------// 1964 //assertEquals("FINAL", getText("//table[@id='row']/tbody/tr[1]/td[4]")); 1965 //selectFrame("relative=up"); 1966 //waitAndClick("link=Main Menu"); 1967 //waitForPageToLoad50000(); 1968 //assertEquals(windowTitles[0], getTitle()); 1969 //-----Step 3 verified that doc is final ------- 1970 } 1971 1972 protected void testIdentityGroupBlanketApprove() throws Exception { 1973 selectFrameIframePortlet(); 1974 waitAndCreateNew(); 1975 String docId = waitForDocId(); 1976 String dtsTwo = ITUtil.createUniqueDtsPlusTwoRandomCharsNot9Digits(); 1977 waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Validation Test Group " + dtsTwo); 1978 assertBlanketApproveButtonsPresent(); 1979 selectByXpath("//select[@id='document.groupNamespace']", AdminTmplMthdSTNavBase.LABEL_KUALI_KUALI_SYSTEMS); 1980 waitAndTypeByXpath("//input[@id='document.groupName']", "Validation Test Group1 " + dtsTwo); 1981 waitAndClickByName( 1982 "methodToCall.performLookup.(!!org.kuali.rice.kim.impl.identity.PersonImpl!!).(((principalId:member.memberId,principalName:member.memberName))).((``)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;;::::).anchorAssignees"); 1983 waitAndClickSearch(); 1984 waitAndClickReturnValue(); 1985 waitAndClickByName("methodToCall.addMember.anchorAssignees"); 1986 waitForPageToLoad(); 1987 blanketApproveTest(); 1988 assertDocFinal(docId); 1989 } 1990 1991 protected void testIdentityPermissionBlanketApprove() throws Exception { 1992 selectFrameIframePortlet(); 1993 waitAndCreateNew(); 1994 String docId = waitForDocId(); 1995 String dtsTwo = ITUtil.createUniqueDtsPlusTwoRandomCharsNot9Digits(); 1996 waitAndTypeByXpath("//input[@name='document.documentHeader.documentDescription']", 1997 "Validation Test Permission " + dtsTwo); 1998 assertBlanketApproveButtonsPresent(); 1999 waitAndTypeByXpath("//input[@name='document.documentHeader.organizationDocumentNumber']", "10012"); 2000 selectByXpath("//select[@name='document.newMaintainableObject.namespaceCode']", 2001 AdminTmplMthdSTNavBase.LABEL_KUALI_KUALI_SYSTEMS); 2002 selectByXpath("//select[@name='document.newMaintainableObject.templateId']", 2003 AdminTmplMthdSTNavBase.LABEL_KUALI_DEFAULT); 2004 waitAndTypeByXpath("//input[@name='document.newMaintainableObject.name']", 2005 "ValidationTestPermission" + dtsTwo); 2006 blanketApproveTest(); 2007 assertDocFinal(docId); 2008 } 2009 2010 protected void testIdentityPersonBlanketApprove() throws Exception { 2011 selectFrameIframePortlet(); 2012 waitAndCreateNew(); 2013 String docId = waitForDocId(); 2014 waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Validation Test Person"); 2015 assertBlanketApproveButtonsPresent(); 2016 waitAndTypeByXpath("//input[@id='document.principalName']", "principal" + RandomStringUtils.randomAlphabetic(3).toLowerCase()); 2017 selectByName("newAffln.affiliationTypeCode", "Affiliate"); 2018 selectByName("newAffln.campusCode", "BX - BLGTN OFF CAMPUS"); 2019 selectByName("newAffln.campusCode", "BL - BLOOMINGTON"); 2020 assertElementPresentByName("newAffln.dflt"); 2021 waitAndClickByName("newAffln.dflt"); 2022 waitAndClickByName("methodToCall.addAffln.anchor"); 2023 waitAndClickByName("methodToCall.toggleTab.tabContact"); 2024 selectByName("newName.namePrefix", "Mr"); 2025 waitAndTypeByName("newName.firstName", "First"); 2026 waitAndTypeByName("newName.lastName", "Last"); 2027 selectByName("newName.nameSuffix", "Mr"); 2028 waitAndClickByName("newName.dflt"); 2029 waitAndClickByName("methodToCall.addName.anchor"); 2030 waitForPageToLoad(); 2031 blanketApproveTest(); 2032 assertDocFinal(docId); 2033 } 2034 2035 protected void testIdentityResponsibilityBlanketApprove() throws Exception { 2036 selectFrameIframePortlet(); 2037 waitAndCreateNew(); 2038 String docId = waitForDocId(); 2039 String dtsTwo = ITUtil.createUniqueDtsPlusTwoRandomCharsNot9Digits(); 2040 waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Validation Test Responsibility " + dtsTwo); 2041 assertBlanketApproveButtonsPresent(); 2042 selectByXpath("//select[@id='document.newMaintainableObject.namespaceCode']", 2043 AdminTmplMthdSTNavBase.LABEL_KUALI_KUALI_SYSTEMS); 2044 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", 2045 "Validation Test Responsibility " + dtsTwo); 2046 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.documentTypeName']", "Test " + dtsTwo); 2047 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.routeNodeName']", "Test " + dtsTwo); 2048 waitAndClickByXpath("//input[@id='document.newMaintainableObject.actionDetailsAtRoleMemberLevel']"); 2049 waitAndClickByXpath("//input[@id='document.newMaintainableObject.required']"); 2050 blanketApproveTest(); 2051 assertDocFinal(docId); 2052 } 2053 2054 protected void testIdentityRoleBlanketApprove() throws Exception { 2055 selectFrameIframePortlet(); 2056 waitAndCreateNew(); 2057 waitAndClickByXpath(SEARCH_XPATH, "No search button to click."); 2058 waitAndClickByLinkText(RETURN_VALUE_LINK_TEXT, "No return value link"); 2059 String docId = waitForDocId(); 2060 String dtsTwo = ITUtil.createUniqueDtsPlusTwoRandomCharsNot9Digits(); 2061 waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Validation Test Role " + dtsTwo); 2062 assertBlanketApproveButtonsPresent(); 2063 selectByXpath("//select[@id='document.roleNamespace']", AdminTmplMthdSTNavBase.LABEL_KUALI_KUALI_SYSTEMS); 2064 waitAndTypeByXpath("//input[@id='document.roleName']", "Validation Test Role " + dtsTwo, 2065 "No Role Name input to type in."); 2066 waitAndClickByName( 2067 "methodToCall.performLookup.(!!org.kuali.rice.kim.impl.identity.PersonImpl!!).(((principalId:member.memberId,principalName:member.memberName))).((``)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;;::::).anchorAssignees"); 2068 waitAndClickByXpath(SEARCH_XPATH, "No search button to click."); 2069 waitAndClickByLinkText(RETURN_VALUE_LINK_TEXT, "No return value link"); 2070 waitAndClickByName("methodToCall.addMember.anchorAssignees"); 2071 waitForPageToLoad(); 2072 blanketApproveTest(); 2073 assertDocFinal(docId); 2074 } 2075 2076 protected void testLocationCampusBlanketApprove() throws Exception { 2077 selectFrameIframePortlet(); 2078 waitAndCreateNew(); 2079 String docId = waitForDocId(); 2080 String twoLetters = RandomStringUtils.randomAlphabetic(2); 2081 waitAndTypeByName("document.documentHeader.documentDescription", "Validation Test Campus " + twoLetters); 2082 assertBlanketApproveButtonsPresent(); 2083 waitAndTypeByName("document.newMaintainableObject.code", RandomStringUtils.randomAlphabetic(2)); 2084 waitAndTypeByName("document.newMaintainableObject.name", "Validation Test Campus" + ITUtil.createUniqueDtsPlusTwoRandomChars()); 2085 waitAndTypeByName("document.newMaintainableObject.shortName", "VTC " + twoLetters); 2086 selectByName("document.newMaintainableObject.campusTypeCode", "B - BOTH"); 2087 blanketApproveTest(); 2088 assertDocFinal(docId); 2089 } 2090 2091 protected void testLocationCountryBlanketApprove() throws InterruptedException { 2092 selectFrameIframePortlet(); 2093 waitAndCreateNew(); 2094 String docId = waitForDocId(); 2095 assertBlanketApproveButtonsPresent(); 2096 String twoUpperCaseLetters = RandomStringUtils.randomAlphabetic(2).toUpperCase(); 2097 String countryName = "Validation Test Country " + ITUtil.createUniqueDtsPlusTwoRandomCharsNot9Digits(); 2098 waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, countryName); 2099 waitAndTypeByXpath(DOC_CODE_XPATH, twoUpperCaseLetters); 2100 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", countryName); 2101 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.alternateCode']", "V" + twoUpperCaseLetters); 2102 blanketApproveTest(); 2103 assertDocFinal(docId); 2104 } 2105 2106 protected void testLocationCountyBlanketApprove() throws Exception { 2107 selectFrameIframePortlet(); 2108 waitAndCreateNew(); 2109 String docId = waitForDocId(); 2110 waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Validation Test County"); 2111 assertBlanketApproveButtonsPresent(); 2112 String countryLookUp = "//input[@name='methodToCall.performLookup.(!!org.kuali.rice.location.impl.country.CountryBo!!).(((code:document.newMaintainableObject.countryCode,))).((`document.newMaintainableObject.countryCode:code,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" 2113 + getBaseUrlString() + "/kr/lookup.do;::::).anchor4']"; 2114 waitAndClickByXpath(countryLookUp); 2115 waitAndTypeByName("code", "US"); 2116 waitAndClickSearch(); 2117 waitAndClickReturnValue(); 2118 waitAndTypeByXpath(DOC_CODE_XPATH, RandomStringUtils.randomAlphabetic(2).toUpperCase()); 2119 String stateLookUp = "//input[@name='methodToCall.performLookup.(!!org.kuali.rice.location.impl.state.StateBo!!).(((countryCode:document.newMaintainableObject.countryCode,code:document.newMaintainableObject.stateCode,))).((`document.newMaintainableObject.countryCode:countryCode,document.newMaintainableObject.stateCode:code,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" 2120 + getBaseUrlString() + "/kr/lookup.do;::::).anchor4']"; 2121 waitAndClickByXpath(stateLookUp); 2122 waitAndTypeByName("code", RandomStringUtils.randomAlphabetic(2)); 2123 waitAndClickSearch(); 2124 waitAndClickReturnValue(); 2125 String countyName = "Validation Test County" + ITUtil.createUniqueDtsPlusTwoRandomChars(); 2126 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", countyName); 2127 waitAndClickByXpath("//input[@id='document.newMaintainableObject.active']"); 2128 blanketApproveTest(); 2129 assertDocFinal(docId); 2130 } 2131 2132 protected void testLocationPostBlanketApprove() throws Exception { 2133 selectFrameIframePortlet(); 2134 waitAndCreateNew(); 2135 String docId = waitForDocId(); 2136 waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Validation Test Postal Code"); 2137 assertBlanketApproveButtonsPresent(); 2138 String countryLookUp = "//input[@name='methodToCall.performLookup.(!!org.kuali.rice.location.impl.country.CountryBo!!).(((code:document.newMaintainableObject.countryCode,))).((`document.newMaintainableObject.countryCode:code,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" 2139 + getBaseUrlString() + "/kr/lookup.do;::::).anchor4']"; 2140 waitAndClickByXpath(countryLookUp); 2141 waitAndTypeByName("code", "US"); 2142 waitAndClickSearch(); 2143 waitAndClickReturnValue(); 2144 String code = RandomStringUtils.randomNumeric(5); 2145 waitAndTypeByXpath(DOC_CODE_XPATH, code); 2146 String stateLookUp = "//input[@name='methodToCall.performLookup.(!!org.kuali.rice.location.impl.state.StateBo!!).(((countryCode:document.newMaintainableObject.countryCode,code:document.newMaintainableObject.stateCode,))).((`document.newMaintainableObject.countryCode:countryCode,document.newMaintainableObject.stateCode:code,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" 2147 + getBaseUrlString() + "/kr/lookup.do;::::).anchor4']"; 2148 waitAndClickByXpath(stateLookUp); 2149 waitAndClickSearch(); 2150 waitAndClickByXpath("//table[@id='row']/tbody/tr[4]/td[1]/a"); 2151 String cityName = "Validation Test Postal Code " + code; 2152 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.cityName']", cityName); 2153 blanketApproveTest(); 2154 assertDocFinal(docId); 2155 } 2156 2157 protected void testLocationStateBlanketApprove() throws Exception { 2158 selectFrameIframePortlet(); 2159 waitAndCreateNew(); 2160 String docId = waitForDocId(); 2161 waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Validation Test State"); 2162 assertBlanketApproveButtonsPresent(); 2163 2164 //jiraAwareWaitAndClick("methodToCall.performLookup.(!!org.kuali.rice.location.impl.country.CountryBo!!).(((code:document.newMaintainableObject.countryCode,))).((`document.newMaintainableObject.countryCode:code,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" + getBaseUrlString() + "/kr/lookup.do;::::).anchor4"); 2165 String countryLookUp = "//input[@name='methodToCall.performLookup.(!!org.kuali.rice.location.impl.country.CountryBo!!).(((code:document.newMaintainableObject.countryCode,))).((`document.newMaintainableObject.countryCode:code,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" 2166 + getBaseUrlString() + "/kr/lookup.do;::::).anchor4']"; 2167 waitAndClickByXpath(countryLookUp); 2168 waitAndClickSearch(); 2169 waitAndClickReturnValue(); 2170 String code = RandomStringUtils.randomAlphabetic(2).toUpperCase(); 2171 waitAndTypeByXpath(DOC_CODE_XPATH, code); 2172 String state = "Validation Test State " + code; 2173 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", state); 2174 waitAndClickByXpath("//input[@id='document.newMaintainableObject.active']"); 2175 blanketApproveTest(); 2176 assertDocFinal(docId); 2177 } 2178 2179 protected void testLookUp() throws Exception { 2180 waitForPageToLoad(); 2181 selectFrameIframePortlet(); 2182 2183 // Mixed capitalization 2184 waitAndClick(By.xpath(SEARCH_XPATH_3)); 2185 waitAndClickByLinkText(EDIT_LINK_TEXT, "edit button not present does user " + user + " have permission?"); 2186 checkForIncidentReport("submit"); 2187 assertTextPresent("ubmit"); 2188 assertTextPresent("ave"); 2189 assertTextPresent("pprove"); 2190 assertTextPresent("lose"); 2191 assertTextPresent("ancel"); 2192 } 2193 2194 protected void performParameterInquiry(String parameterField) throws Exception { 2195 waitAndTypeByName("name", parameterField); 2196 waitAndClickSearch(); 2197 isElementPresentByLinkText(parameterField); 2198 waitAndClickByLinkText(parameterField); 2199 waitForPageToLoad(); 2200 Thread.sleep(2000); 2201 switchToWindow("Kuali :: Inquiry"); 2202 Thread.sleep(2000); 2203 } 2204 2205 protected List<String> testLookUpParameterType(String docId, String parameterType, String parameterCode) throws Exception { 2206 performParameterInquiry(parameterType); 2207 SeleneseTestBase.assertEquals(parameterCode, getTextByXpath("//div[@class='tab-container']/table//span[@id='code.div']").trim().toLowerCase()); 2208 SeleneseTestBase.assertEquals(parameterType, getTextByXpath("//div[@class='tab-container']/table//span[@id='name.div']").trim().toLowerCase()); 2209 waitAndClickCloseWindow(); 2210 switchToWindow("null"); 2211 List<String> params = new ArrayList<String>(); 2212 params.add(docId); 2213 params.add(parameterType); 2214 params.add(parameterCode); 2215 2216 return params; 2217 } 2218 2219 protected List<String> testLookUpParameter(String docId, String parameterName) throws Exception { 2220 performParameterInquiry(parameterName); 2221 SeleneseTestBase.assertEquals(parameterName, getTextByXpath( 2222 "//div[@class='tab-container']/table//span[@id='name.div']").trim()); 2223 SeleneseTestBase.assertEquals("Y", getTextByXpath("//div[@class='tab-container']/table//span[@id='value.div']") 2224 .trim()); 2225 waitAndClickCloseWindow(); 2226 switchToWindow("null"); 2227 List<String> params = new ArrayList<String>(); 2228 params.add(docId); 2229 params.add(parameterName); 2230 2231 return params; 2232 } 2233 2234 protected void testPeopleFlow() throws Exception { 2235 selectFrameIframePortlet(); 2236 2237 //Click Main Menu and Create New 2238 // waitAndCreateNew(); 2239 // waitForPageToLoad(); 2240 jGrowl("Create New"); 2241 waitAndClickByLinkText("Create New"); 2242 2243 //jiraAwareWaitAndClick(By.linkText("Create New")); 2244 //Save docId 2245 waitForElementPresent("div[data-header_for='PeopleFlow-MaintenanceView'] div[data-label='Document Number'] > span"); 2246 String docId = getText("div[data-header_for='PeopleFlow-MaintenanceView'] div[data-label='Document Number'] > span"); 2247 jGrowlSticky("Doc Id is " + docId); 2248 driver.findElement(By.name("document.documentHeader.documentDescription")).clear(); 2249 driver.findElement(By.name("document.documentHeader.documentDescription")).sendKeys("Description for Document"); 2250 new Select(driver.findElement(By.name("document.newMaintainableObject.dataObject.namespaceCode"))).selectByVisibleText("KUALI - Kuali Systems"); 2251 driver.findElement(By.name("document.newMaintainableObject.dataObject.name")).clear(); 2252 driver.findElement(By.name("document.newMaintainableObject.dataObject.name")).sendKeys("Document Name" + ITUtil.DTS); 2253 2254 jGrowl("Add Member kr"); 2255 driver.findElement(By.name("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName")).clear(); 2256 driver.findElement(By.name("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName")).sendKeys("kr"); 2257 driver.findElement(By.cssSelector("button[data-loadingmessage='Adding Line...']")).click(); 2258 Thread.sleep(3000); 2259 2260 jGrowl("Add Member admin"); 2261 driver.findElement(By.name("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName")).clear(); 2262 driver.findElement(By.name("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName")).sendKeys("admin"); 2263 driver.findElement(By.cssSelector("button[data-loadingmessage='Adding Line...']")).click(); 2264 Thread.sleep(3000); 2265 2266 driver.findElement(By.cssSelector("div[data-parent='PeopleFlow-MaintenanceView'] > div.uif-footer button~button~button")).click(); 2267 jGrowl("Blanket Approve"); 2268 Thread.sleep(5000); 2269 2270 //Close the Doc 2271 //driver.findElement(By.id("uif-close")).click(); 2272 //Thread.sleep(3000); 2273 driver.switchTo().window(driver.getWindowHandles().toArray()[0].toString()); 2274 driver.findElement(By.cssSelector("img[alt=\"doc search\"]")).click(); 2275 Thread.sleep(5000); 2276 jGrowl("Document Search is " + docId + " present?"); 2277 selectFrameIframePortlet(); 2278 driver.findElement(By.cssSelector("td.infoline > input[name=\"methodToCall.search\"]")).click(); 2279 Thread.sleep(5000); 2280 jGrowl("Is doc status final?"); 2281 SeleneseTestBase.assertEquals(DOC_STATUS_FINAL, driver.findElement(By.xpath("//table[@id='row']/tbody/tr/td[4]")).getText()); 2282 driver.switchTo().defaultContent(); 2283 driver.findElement(By.name("imageField")).click(); 2284 Thread.sleep(5000); 2285 // TODO open the document and verify data is as we expect. 2286 } 2287 2288 protected void testTermLookupAssertions() throws Exception { 2289 testLookUp(); 2290 assertTextPresent("Term Parameters"); 2291 waitAndClick(By.xpath(CANCEL2_XPATH)); 2292 passed(); 2293 } 2294 2295 protected void testTermSpecificationLookupAssertions() throws Exception { 2296 testLookUp(); 2297 assertTextPresent("Context"); 2298 waitAndClick(By.xpath(CANCEL2_XPATH)); 2299 passed(); 2300 } 2301 2302 protected List<String> testVerifyModifiedParameter(String docId, String parameterName) throws Exception { 2303 performParameterInquiry(parameterName); 2304 SeleneseTestBase.assertEquals(parameterName, getTextByXpath("//div[@class='tab-container']/table//span[@id='name.div']").trim()); 2305 SeleneseTestBase.assertEquals("N", getTextByXpath("//div[@class='tab-container']/table//span[@id='value.div']").trim()); 2306 waitAndClickCloseWindow(); 2307 switchToWindow("null"); 2308 List<String> params = new ArrayList<String>(); 2309 params.add(docId); 2310 params.add(parameterName); 2311 2312 return params; 2313 } 2314 2315 protected List<String> testVerifyCopyParameterType(String docId, String parameterType, String parameterCode) throws Exception 2316 { 2317 performParameterInquiry(parameterType); 2318 SeleneseTestBase.assertEquals(parameterType, getTextByXpath("//div[@class='tab-container']/table//span[@id='name.div']").trim().toLowerCase()); 2319 waitAndClickCloseWindow(); 2320 switchToWindow("null"); 2321 List<String> params = new ArrayList<String>(); 2322 params.add(docId); 2323 params.add(parameterType); 2324 params.add(parameterCode); 2325 2326 return params; 2327 } 2328 2329 protected List<String> testCreateNewPermission(String docId, String permissionName) throws Exception 2330 { 2331 waitForPageToLoad(); 2332 Thread.sleep(2000); 2333 docId = waitForDocId(); 2334 waitAndClickSave(); 2335 waitForPageToLoad(); 2336 assertElementPresentByXpath("//div[contains(.,'Document Description (Description) is a required field.')]/img[@alt='error']"); 2337 waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Adding Permission removeme"); 2338 waitAndClickSubmit(); 2339 waitForPageToLoad(); 2340 assertElementPresentByXpath("//div[@class='error']"); 2341 assertElementPresentByXpath("//div[contains(.,'Template (Template) is a required field.')]/img[@alt='error']"); 2342 assertElementPresentByXpath("//div[contains(.,'Permission Namespace (Permission Namespace) is a required field.')]/img[@alt='error']"); 2343 assertElementPresentByXpath("//div[contains(.,'Permission Name (Permission Name) is a required field.')]/img[@alt='error']"); 2344 selectOptionByName("document.newMaintainableObject.templateId", "36"); 2345 selectOptionByName("document.newMaintainableObject.namespaceCode", "KR-SYS"); 2346 permissionName = "removeme" + ITUtil.createUniqueDtsPlusTwoRandomChars(); 2347 waitAndTypeByName("document.newMaintainableObject.name", permissionName); 2348 waitAndTypeByName("document.newMaintainableObject.description", "namespaceCode=KR*"); 2349 checkByName("document.newMaintainableObject.active"); 2350 waitAndClickSave(); 2351 waitForPageToLoad(); 2352 assertElementPresentByXpath(SAVE_SUCCESSFUL_XPATH); 2353 SeleneseTestBase.assertEquals(DOC_STATUS_SAVED, getTextByXpath(DOC_STATUS_XPATH)); 2354 waitAndClickSubmit(); 2355 waitForPageToLoad(); 2356 assertElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH,"Document is not submitted successfully"); 2357 SeleneseTestBase.assertEquals(DOC_STATUS_ENROUTE, getTextByXpath(DOC_STATUS_XPATH)); 2358 List<String> params = new ArrayList<String>(); 2359 params.add(docId); 2360 params.add(permissionName); 2361 2362 return params; 2363 } 2364 2365 protected List<String> testLookUpPermission(String docId, String permissionName) throws Exception 2366 { 2367 waitForPageToLoad(); 2368 waitAndTypeByName("name", permissionName); 2369 waitAndClickSearch(); 2370 isElementPresentByLinkText(permissionName); 2371 List<String> params = new ArrayList<String>(); 2372 params.add(docId); 2373 params.add(permissionName); 2374 2375 return params; 2376 } 2377 2378 protected List<String> testEditPermission(String docId, String permissionName) throws Exception 2379 { 2380 waitAndClickEdit(); 2381 waitForPageToLoad(); 2382 Thread.sleep(2000); 2383 waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Editing Permission removeme"); 2384 uncheckByName("document.newMaintainableObject.active"); 2385 waitAndClickSubmit(); 2386 waitForPageToLoad(); 2387 assertElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH, "Document is not submitted successfully"); 2388 List<String> params = new ArrayList<String>(); 2389 params.add(docId); 2390 params.add(permissionName); 2391 2392 return params; 2393 } 2394 2395 protected List<String> testVerifyPermission(String docId, String permissionName) throws Exception 2396 { 2397 waitForPageToLoad(); 2398 waitAndTypeByName("name", permissionName); 2399 waitAndClickByXpath("//input[@title='Active Indicator - No']"); 2400 waitAndClickSearch(); 2401 isElementPresentByLinkText(permissionName); 2402 List<String> params = new ArrayList<String>(); 2403 params.add(docId); 2404 params.add(permissionName); 2405 2406 return params; 2407 } 2408 2409 protected List<String> testCreateNewPerson(String docId, String personName) throws Exception 2410 { 2411 waitForPageToLoad(); 2412 docId = waitForDocId(); 2413 waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Adding Charlie Brown"); 2414 waitAndTypeByName("document.documentHeader.explanation", "I want to add Charlie Brown to test KIM"); 2415 2416 //here You should also check for lower case validation for principalName, but it is skipped for now as there is an incident report error there. 2417 personName = "cbrown" + ITUtil.createUniqueDtsPlusTwoRandomChars(); 2418 waitAndTypeByName("document.principalName", personName); 2419 waitAndClickSave(); 2420 waitForPageToLoad(); 2421 assertElementPresentByXpath(SAVE_SUCCESSFUL_XPATH); 2422 SeleneseTestBase.assertEquals(DOC_STATUS_SAVED, getTextByXpath(DOC_STATUS_XPATH)); 2423 waitAndClickSubmit(); 2424 waitForPageToLoad(); 2425 assertElementPresentByXpath("//div[contains(.,'At least one affiliation must be entered.')]/img[@alt='error']"); 2426 assertElementPresentByXpath("//div[contains(.,'At least one name must be entered.')]/img[@alt='error']"); 2427 selectOptionByName("newAffln.affiliationTypeCode", "STDNT"); 2428 selectOptionByName("newAffln.campusCode", "BL"); 2429 checkByName("newAffln.dflt"); 2430 waitAndClickByName("methodToCall.addAffln.anchor"); 2431 waitForPageToLoad(); 2432 Thread.sleep(3000); 2433 selectOptionByName("newName.nameCode", "PRM"); 2434 selectOptionByName("newName.namePrefix", "Mr"); 2435 waitAndTypeByName("newName.firstName", "Charlie"); 2436 waitAndTypeByName("newName.lastName", "Brown"); 2437 checkByName("newName.dflt"); 2438 waitAndClickByName("methodToCall.addName.anchor"); 2439 waitForPageToLoad(); 2440 waitAndClickSubmit(); 2441 waitForPageToLoad(); 2442 assertElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH, "Document is not submitted successfully"); 2443 SeleneseTestBase.assertEquals(DOC_STATUS_ENROUTE, getTextByXpath(DOC_STATUS_XPATH)); 2444 List<String> params = new ArrayList<String>(); 2445 params.add(docId); 2446 params.add(personName); 2447 2448 return params; 2449 } 2450 2451 protected List<String> testLookUpPerson(String docId, String personName) throws Exception 2452 { 2453 waitForPageToLoad(); 2454 waitAndTypeByName("principalName", personName); 2455 waitAndClickSearch(); 2456 isElementPresentByLinkText(personName); 2457 waitAndClickByName("methodToCall.clearValues"); 2458 waitAndTypeByName("firstName", "Charlie"); 2459 waitAndClickSearch(); 2460 isElementPresentByLinkText(personName); 2461 waitAndClickByName("methodToCall.clearValues"); 2462 waitAndTypeByName("lastName", "Brown"); 2463 waitAndClickSearch(); 2464 isElementPresentByLinkText(personName); 2465 waitAndClickByName("methodToCall.clearValues"); 2466 waitAndTypeByName("campusCode", "BL"); 2467 waitAndClickSearch(); 2468 isElementPresentByLinkText(personName); 2469 List<String> params = new ArrayList<String>(); 2470 params.add(docId); 2471 params.add(personName); 2472 2473 return params; 2474 } 2475 2476 protected List<String> testVerifyPerson(String docId, String personName) throws Exception 2477 { 2478 waitAndClickByLinkText(personName); 2479 waitForPageToLoad(); 2480 Thread.sleep(5000); 2481 switchToWindow("Kuali :: Person"); 2482 Thread.sleep(2000); 2483 SeleneseTestBase.assertEquals(personName, getTextByXpath("//div[@class='tab-container']/table//tr[2]/td[1]/div").trim()); 2484 SeleneseTestBase.assertEquals("BL - BLOOMINGTON", getTextByXpath("//div[@class='tab-container']/table[3]//tr[2]/td[2]/div").trim()); 2485 SeleneseTestBase.assertEquals("Student", getTextByXpath("//select/option[@selected]").trim()); 2486 assertElementPresentByXpath("//table[@class='tab']//input[@title='close Overview']"); 2487 assertElementPresentByXpath("//table[@class='tab']//input[@title='open Contact']"); 2488 assertElementPresentByXpath("//table[@class='tab']//input[@title='open Privacy Preferences']"); 2489 assertElementPresentByXpath("//table[@class='tab']//input[@title='open Membership']"); 2490 waitAndClickByName("methodToCall.showAllTabs"); 2491 Thread.sleep(3000); 2492 assertElementPresentByXpath("//table[@class='tab']//input[@title='close Overview']"); 2493 assertElementPresentByXpath("//table[@class='tab']//input[@title='close Contact']"); 2494 assertElementPresentByXpath("//table[@class='tab']//input[@title='close Privacy Preferences']"); 2495 assertElementPresentByXpath("//table[@class='tab']//input[@title='close Membership']"); 2496 waitAndClickByName("methodToCall.hideAllTabs"); 2497 Thread.sleep(3000); 2498 assertElementPresentByXpath("//table[@class='tab']//input[@title='open Overview']"); 2499 assertElementPresentByXpath("//table[@class='tab']//input[@title='open Contact']"); 2500 assertElementPresentByXpath("//table[@class='tab']//input[@title='open Privacy Preferences']"); 2501 assertElementPresentByXpath("//table[@class='tab']//input[@title='open Membership']"); 2502 waitAndClickCloseWindow(); 2503 switchToWindow("null"); 2504 List<String> params = new ArrayList<String>(); 2505 params.add(docId); 2506 params.add(personName); 2507 2508 return params; 2509 } 2510 2511 protected void testUifTooltip(String NAME_FIELD_1, String NAME_FIELD_2) throws Exception { 2512 // check if tooltip opens on focus 2513 fireEvent(NAME_FIELD_1, "focus"); 2514 fireMouseOverEventByName(NAME_FIELD_1); 2515 2516 // SeleneseTestBase.assertTrue(isVisible("div.jquerybubblepopup.jquerybubblepopup-black") && isVisible("td.jquerybubblepopup-innerHtml")); 2517 SeleneseTestBase.assertEquals("This tooltip is triggered by focus or and mouse over.", getText( 2518 "td.jquerybubblepopup-innerHtml")); 2519 2520 // check if tooltip closed on blur 2521 fireEvent(NAME_FIELD_1, "blur"); 2522 SeleneseTestBase.assertFalse(isVisible("div.jquerybubblepopup.jquerybubblepopup-black") && isVisible( 2523 "td.jquerybubblepopup-innerHtml")); 2524 Thread.sleep(5000); 2525 fireEvent("field119", "focus"); 2526 2527 // check if tooltip opens on mouse over 2528 fireMouseOverEventByName(NAME_FIELD_2); 2529 SeleneseTestBase.assertTrue(isVisibleByXpath("//td[contains(.,\"This is a tool-tip with different position and tail options\")]")); 2530 2531 // check if tooltip closed on mouse out 2532 waitAndTypeByName(NAME_FIELD_2, "a"); 2533 Thread.sleep(5000); 2534 SeleneseTestBase.assertFalse(isVisibleByXpath( 2535 "//td[contains(.,\"This is a tool-tip with different position and tail options\")]")); 2536 2537 // check that default tooltip does not display when there are an error message on the field 2538 waitAndTypeByName(NAME_FIELD_1, "1"); 2539 fireEvent(NAME_FIELD_1, "blur"); 2540 fireMouseOverEventByName(NAME_FIELD_1); 2541 Thread.sleep(10000); 2542 SeleneseTestBase.assertTrue("https://jira.kuali.org/browse/KULRICE-8141 Investigate why UifTooltipIT.testTooltip fails around jquerybubblepopup", 2543 isVisibleByXpath("//div[@class='jquerybubblepopup jquerybubblepopup-kr-error-cs']") && 2544 !(isVisibleByXpath("//div[@class='jquerybubblepopup jquerybubblepopup-black']"))); 2545 2546 // TODO figure out this last assert 2547 passed(); 2548 } 2549 2550 protected void testValidCharsConstraintIT() throws Exception { 2551 assertFocusTypeBlurValidation("field50", new String[]{"12.333", "-123.33"}, new String[]{"123.33"}); 2552 assertFocusTypeBlurValidation("field51", new String[]{"A"}, new String[]{"-123.33"}); 2553 2554 // TODO continue to convert to assertFocusTypeBlurValidation 2555 assertFocusTypeBlurValidation("field77", new String[]{"1.1"},new String[]{"12"}); 2556 assertFocusTypeBlurValidation("field52", new String[]{"5551112222"},new String[]{"555-111-1111"}); 2557 assertFocusTypeBlurValidation("field53", new String[]{"1ClassName.java"},new String[]{"ClassName.java"}); 2558 assertFocusTypeBlurValidation("field54", new String[]{"aaaaa"},new String[]{"aaaaa@kuali.org"}); 2559 assertFocusTypeBlurValidation("field84", new String[]{"aaaaa"},new String[]{"http://www.kuali.org"}); 2560 assertFocusTypeBlurValidation("field55", new String[]{"023512"},new String[]{"022812"}); 2561 assertFocusTypeBlurValidation("field75", new String[]{"02/35/12"},new String[]{"02/28/12"}); 2562 assertFocusTypeBlurValidation("field82", new String[]{"13:22"},new String[]{"02:33"}); 2563 assertFocusTypeBlurValidation("field83", new String[]{"25:22"},new String[]{"14:33"}); 2564 assertFocusTypeBlurValidation("field57", new String[]{"0"},new String[]{"2020"}); 2565 assertFocusTypeBlurValidation("field58", new String[]{"13"},new String[]{"12"}); 2566 assertFocusTypeBlurValidation("field61", new String[]{"5555-444"},new String[]{"55555-4444"}); 2567 assertFocusTypeBlurValidation("field62", new String[]{"aa5bb6_a"},new String[]{"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"}); 2568 assertFocusTypeBlurValidation("field63", new String[]{"fff555"},new String[]{"aa22 _/"}); 2569 assertFocusTypeBlurValidation("field64", new String[]{"AABB55"},new String[]{"ABCDEFGHIJKLMNOPQRSTUVWXY,Z abcdefghijklmnopqrstuvwxy,z"}); 2570 assertFocusTypeBlurValidation("field76", new String[]{"AA~BB%"},new String[]{"abcABC %$#@&<>\\{}[]*-+!=.()/\"\"',:;?"}); 2571 assertFocusTypeBlurValidation("field65", new String[]{"sdfs$#$# dsffs"},new String[]{"sdfs$#$#sffs"}); 2572 assertFocusTypeBlurValidation("field66", new String[]{"abcABCD"},new String[]{"ABCabc"}); 2573 assertFocusTypeBlurValidation("field67", new String[]{"(111)B-(222)A"},new String[]{"(12345)-(67890)"}); 2574 assertFocusTypeBlurValidation("field68", new String[]{"A.66"},new String[]{"a.4"}); 2575 assertFocusTypeBlurValidation("field56", new String[]{"2020-06-02"},new String[]{"2020-06-02 03:30:30.22"}); 2576 } 2577 2578 protected void assertFocusTypeBlurValidation(String field, String[] errorInputs, String[] validInputs) throws InterruptedException { 2579 assertFocusTypeBlurError(field, errorInputs); 2580 clearTextByName(field); 2581 assertFocusTypeBlurValid(field, validInputs); 2582 } 2583 2584 protected void testSubCollectionSize() throws Exception { 2585 checkForIncidentReport(COLLECTIONS_LINK_TEXT); 2586 2587 // click on collections page link 2588 waitAndClickByLinkText(COLLECTIONS_LINK_TEXT); 2589 2590 // wait for collections page to load by checking the presence of a sub collection line item 2591 for (int second = 0;; second++) { 2592 if (second >= waitSeconds) 2593 failableFail(TIMEOUT_MESSAGE + " looking for " + SUB_COLLECTION_UIF_DISCLOSURE_SPAN_UIF_HEADER_TEXT_SPAN_XPATH); 2594 try { 2595 if (getText(SUB_COLLECTION_UIF_DISCLOSURE_SPAN_UIF_HEADER_TEXT_SPAN_XPATH).equals("SubCollection - (3 lines)")) 2596 { 2597 break; 2598 } 2599 } catch (Exception e) {} 2600 Thread.sleep(1000); 2601 } 2602 2603 // verify that sub collection sizes are displayed as expected 2604 SeleneseTestBase.assertEquals("SubCollection - (3 lines)", getText(SUB_COLLECTION_UIF_DISCLOSURE_SPAN_UIF_HEADER_TEXT_SPAN_XPATH)); 2605 SeleneseTestBase.assertEquals("SubCollection - (2 lines)", getTextByXpath( 2606 "//a[@id='subCollection1_line1_toggle']/span")); 2607 } 2608 2609 protected void testConfigurationTestView(String idPrefix) throws Exception { 2610 waitForElementPresentByXpath("//span[@id='" + idPrefix + "TextInputField_label_span']"); 2611 2612 // testing for https://groups.google.com/a/kuali.org/group/rice.usergroup.krad/browse_thread/thread/1e501d07c1141aad# 2613 String styleValue = getAttributeByXpath("//span[@id='" + idPrefix + "TextInputField_label_span']", "style"); 2614 2615 // log.info("styleValue is " + styleValue); 2616 SeleneseTestBase.assertTrue(idPrefix + "textInputField label does not contain expected style", styleValue.replace(" ", "").contains("color:red")); 2617 2618 // get current list of options 2619 String refreshTextSelectLocator = "//select[@id='" + idPrefix + "RefreshTextField_control']"; 2620 String[] options1 = getSelectOptionsByXpath(refreshTextSelectLocator); 2621 String dropDownSelectLocator = "//select[@id='" + idPrefix + "DropDown_control']"; 2622 selectByXpath(dropDownSelectLocator, "Vegetables"); 2623 Thread.sleep(3000); 2624 2625 //get list of options after change 2626 String[] options2 = getSelectOptionsByXpath(refreshTextSelectLocator); 2627 2628 //verify that the change has occurred 2629 SeleneseTestBase.assertFalse( 2630 "Field 1 selection did not change Field 2 options https://jira.kuali.org/browse/KULRICE-8163 Configuration Test View Conditional Options doesn't change Field 2 options based on Field 1 selection", 2631 options1[options1.length - 1].equalsIgnoreCase(options2[options2.length - 1])); 2632 2633 //confirm that control gets disabled 2634 selectByXpath(dropDownSelectLocator, "None"); 2635 Thread.sleep(3000); 2636 SeleneseTestBase.assertEquals("true", getAttributeByXpath(refreshTextSelectLocator, "disabled")); 2637 } 2638 2639 /** 2640 * verify that add line controls are present 2641 */ 2642 protected void confirmAddLineControlsPresent(String idPrefix, String addLineIdSuffix) { 2643 String[] addLineIds = {"StartTime", "StartTimeAmPm", "AllDay"}; 2644 2645 for (String id : addLineIds) { 2646 String tagId = "//*[@id='" + idPrefix + id + addLineIdSuffix + "']"; 2647 SeleneseTestBase.assertTrue("Did not find id " + tagId, isElementPresentByXpath(tagId)); 2648 } 2649 } 2650 2651 protected void testAddLineWithSpecificTime(String idPrefix, String addLineIdSuffix) throws Exception { 2652 waitForElementPresentByXpath("//span[@id='" + idPrefix + "TextInputField_label_span']"); 2653 confirmAddLineControlsPresent(idPrefix, addLineIdSuffix); 2654 String startTimeId = "//*[@id='" + idPrefix + "StartTime" + addLineIdSuffix + "']"; 2655 String inputTime = "7:06"; 2656 waitAndTypeByXpath(startTimeId, inputTime); 2657 String amPmSelectLocator = "//*[@id='" + idPrefix + "StartTimeAmPm" + addLineIdSuffix + "']"; 2658 selectByXpath(amPmSelectLocator, "PM"); 2659 SeleneseTestBase.assertEquals("PM", getAttributeByXpath(amPmSelectLocator, "value")); 2660 Thread.sleep(5000); //allow for ajax refresh 2661 waitAndClickByXpath("//button"); 2662 Thread.sleep(5000); //allow for line to be added 2663 2664 //confirm that line has been added 2665 SeleneseTestBase.assertTrue("line (//input[@value='7:06'])is not present https://jira.kuali.org/browse/KULRICE-8162 Configuration Test View Time Info add line button doesn't addline", 2666 isElementPresentByXpath("//input[@value='7:06']")); 2667 } 2668 2669 protected void testAddLineWithAllDay(String idPrefix, String addLineIdSuffix) throws Exception { 2670 waitForElementPresentByXpath("//span[@id='" + idPrefix + "TextInputField_label_span']"); 2671 confirmAddLineControlsPresent(idPrefix, addLineIdSuffix); 2672 String startTimeId = "//*[@id='" + idPrefix + "StartTime" + addLineIdSuffix + "']"; 2673 String inputTime = "5:20"; 2674 waitAndTypeByXpath(startTimeId, inputTime); 2675 String allDaySelector = "//*[@id='" + idPrefix + "AllDay" + addLineIdSuffix + "']"; 2676 Thread.sleep(5000); //allow for ajax refresh 2677 waitAndClickByXpath(allDaySelector); 2678 Thread.sleep(5000); //allow for ajax refresh 2679 waitAndClick("div#ConfigurationTestView-ProgressiveRender-TimeInfoSection button"); 2680 Thread.sleep(5000); //allow for line to be added 2681 } 2682 2683 protected void testAddLineAllDay(String idPrefix, String addLineIdSuffix) throws Exception { 2684 waitForElementPresentByXpath("//span[@id='" + idPrefix + "TextInputField_label_span']"); 2685 confirmAddLineControlsPresent(idPrefix, addLineIdSuffix); 2686 2687 //store number of rows before adding the lines 2688 String cssCountRows = "div#ConfigurationTestView-ProgressiveRender-TimeInfoSection.uif-group div#ConfigurationTestView-ProgressiveRender-TimeInfoSection_disclosureContent.uif-disclosureContent table tbody tr"; 2689 int rowCount = (getCssCount(cssCountRows)); 2690 String allDayId = "//*[@id='" + idPrefix + "AllDay" + addLineIdSuffix + "']"; 2691 Thread.sleep(5000); //allow for ajax refresh 2692 waitAndClickByXpath(allDayId); 2693 waitAndClick("div#ConfigurationTestView-ProgressiveRender-TimeInfoSection button"); 2694 Thread.sleep(5000); //allow for line to be added 2695 2696 //confirm that line has been added (by checking for the new delete button) 2697 assertEquals("line was not added", rowCount + 1, (getCssCount(cssCountRows))); 2698 } 2699 2700 // protected void testTravelAccountTypeLookup() throws Exception { 2701 // selectFrameIframePortlet(); 2702 // 2703 // //Blank Search 2704 // waitAndClickByXpath("//*[contains(button,\"earch\")]/button[1]"); 2705 // Thread.sleep(4000); 2706 // assertElementPresentByXpath("//table[@class='uif-tableCollectionLayout dataTable']//tr[contains(td[1],'CAT')]"); 2707 // assertElementPresentByXpath("//table[@class='uif-tableCollectionLayout dataTable']//tr[contains(td[1],'EAT')]"); 2708 // assertElementPresentByXpath("//table[@class='uif-tableCollectionLayout dataTable']//tr[contains(td[1],'IAT')]"); 2709 // 2710 // //search with each field 2711 // waitAndTypeByName("lookupCriteria[accountTypeCode]", "CAT"); 2712 // waitAndClickByXpath("//*[contains(button,\"earch\")]/button[1]"); 2713 // Thread.sleep(2000); 2714 // assertElementPresentByXpath("//table[@class='uif-tableCollectionLayout dataTable']//tr[contains(td[1],'CAT')]"); 2715 // waitAndClickByXpath("//*[contains(button,\"earch\")]/button[2]"); 2716 // Thread.sleep(2000); 2717 // waitAndTypeByName("lookupCriteria[name]", "Expense Account Type"); 2718 // waitAndClickByXpath("//*[contains(button,\"earch\")]/button[1]"); 2719 // Thread.sleep(4000); 2720 // assertElementPresentByXpath("//table[@class='uif-tableCollectionLayout dataTable']//tr[contains(td[1],'EAT')]"); 2721 // 2722 // //Currently No links available for Travel Account Type Inquiry so cant verify heading and values. 2723 // } 2724 2725 protected void testCategoryLookUp() throws Exception { 2726 waitForPageToLoad(); 2727 selectFrameIframePortlet(); 2728 waitAndClickByXpath("//button[contains(.,'earch')]"); 2729 Thread.sleep(3000); 2730 waitForPageToLoad(); 2731 driver.findElement(By.tagName("body")).getText().contains("Actions"); // there are no actions, but the header is the only unique text from searching 2732 2733 // Category's don't have actions (yet) 2734 //waitAndClick("id=u80"); 2735 //waitForPageToLoad(); 2736 //waitAndClick("id=u86"); 2737 //waitForPageToLoad(); 2738 //selectWindow("null"); 2739 //waitAndClick("xpath=(//input[@name='imageField'])[2]"); 2740 //waitForPageToLoad(); 2741 //passed(); 2742 } 2743 2744 protected void testCreateSampleEDocLite() throws Exception { 2745 waitForPageToLoad(); 2746 Thread.sleep(3000); 2747 SeleneseTestBase.assertEquals("Kuali Portal Index", getTitle()); 2748 selectFrameIframePortlet(); 2749 waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']"); 2750 waitForPageToLoad(); 2751 2752 // click on the create new. 2753 waitAndClickByLinkText("Create Document"); 2754 waitForPageToLoad(); 2755 Thread.sleep(3000); 2756 String docId = getTextByXpath("//table/tbody/tr[4]/td[@class='datacell1']"); 2757 waitAndTypeByName("userName", "Viral Chauhan"); 2758 waitAndTypeByName("rqstDate", "12/03/2020"); 2759 checkByName("fundedBy"); 2760 waitAndTypeByName("addText", "Note Added."); 2761 waitAndClickByXpath("//td[@class='datacell']/div/img"); 2762 waitForPageToLoad(); 2763 waitAndClickByXpath("//input[@value='submit']"); 2764 SeleneseTestBase.assertEquals(Boolean.FALSE,(Boolean) isElementPresentByXpath("//input[@value='submit']")); 2765 SeleneseTestBase.assertEquals(Boolean.FALSE, (Boolean) isElementPresentByXpath("//input[@value='save']")); 2766 SeleneseTestBase.assertEquals(Boolean.FALSE,(Boolean) isElementPresentByXpath("//input[@value='cancel']")); 2767 waitForPageToLoad(); 2768 selectTopFrame(); 2769 waitAndClickDocSearch(); 2770 waitForPageToLoad(); 2771 selectFrameIframePortlet(); 2772 waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']"); 2773 waitForPageToLoad(); 2774 isElementPresent(By.linkText(docId)); 2775 } 2776 2777 protected void testTermLookUp() throws Exception { 2778 testLookUp(); 2779 assertTextPresent("Term Parameters"); 2780 waitAndClick(By.xpath(CANCEL2_XPATH)); 2781 passed(); 2782 } 2783 2784 protected void testWorkFlowRouteRulesBlanketApp() throws Exception { 2785 waitForPageToLoad(); 2786 Thread.sleep(3000); 2787 SeleneseTestBase.assertEquals("Kuali Portal Index", getTitle()); 2788 selectFrameIframePortlet(); 2789 2790 // click on the create new button 2791 waitAndClickCreateNew(); 2792 waitForPageToLoad(); 2793 2794 // lookup on the Document Type Name 2795 waitAndClickByName("methodToCall.performLookup.(!!org.kuali.rice.kew.doctype.bo.DocumentType!!).(((name:documentTypeName))).((``)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;;::::).anchor"); 2796 waitForPageToLoad(); 2797 2798 // type in the name field the text RoutingRuleDocument 2799 waitAndTypeByName("name", "RoutingRuleDocument"); 2800 2801 // click the search button 2802 waitAndClickSearch(); 2803 waitForPageToLoad(); 2804 2805 // click the return value link 2806 waitAndClickReturnValue(); 2807 waitForPageToLoad(); 2808 2809 // lookup on the Rule Template Name 2810 waitAndClickByName("methodToCall.performLookup.(!!org.kuali.rice.kew.rule.bo.RuleTemplateBo!!).(((name:ruleTemplateName))).((``)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;;::::).anchor"); 2811 waitForPageToLoad(); 2812 2813 // type in the name field the text RuleRoutingTemplate 2814 waitAndTypeByName("name", "RuleRoutingTemplate"); 2815 2816 // click the search button 2817 waitAndClickSearch(); 2818 waitForPageToLoad(); 2819 2820 // click the return value link 2821 waitAndClickReturnValue(); 2822 waitForPageToLoad(); 2823 2824 // click the create new button 2825 waitAndClickByName("methodToCall.createRule"); 2826 waitForPageToLoad(); 2827 String docId = waitForDocId(); 2828 SeleneseTestBase.assertTrue(isElementPresentByName(CANCEL_NAME)); 2829 2830 // type in the Document Overview Description the text Test Routing Rule 2831 waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Test Routing Rule"); 2832 2833 // click the Force Action checkbox 2834 waitAndClickByXpath("//input[@id='document.newMaintainableObject.forceAction']"); 2835 2836 // type in the Description text area the text Test Routing Rule1 2837 waitAndTypeByXpath("//textarea[@id='document.newMaintainableObject.description']", "Test Routing Rule1"); 2838 2839 // type in the Document type name field the text DocumentTypeDocument 2840 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.fieldValues(1321~docTypeFullName)']", 2841 "DocumentTypeDocument"); 2842 2843 // lookup on Person 2844 waitAndClickByName("methodToCall.performLookup.(!!org.kuali.rice.kim.impl.identity.PersonImpl!!).(((principalName:document.newMaintainableObject.add.personResponsibilities.principalName,))).((`document.newMaintainableObject.add.personResponsibilities.principalName:principalName,`)).((<>)).(([])).((**)).((^^)).((&&)).((/personImpl/)).((~~)).(::::;" 2845 + getBaseUrlString() + "/kr/lookup.do;::::).anchor15"); 2846 waitForPageToLoad(); 2847 2848 // click the search button 2849 waitAndClickSearch(); 2850 waitForPageToLoad(); 2851 2852 // click the return value 2853 waitAndClickReturnValue(); 2854 waitForPageToLoad(); 2855 2856 // select from the Action Request ACKNOWLEDGE 2857 selectByXpath("//select[@id='document.newMaintainableObject.add.personResponsibilities.actionRequestedCd']", 2858 "ACKNOWLEDGE"); 2859 2860 // type in the Priority field the text 1 2861 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.add.personResponsibilities.priority']", "1"); 2862 2863 // click the add button 2864 waitAndClickByName("methodToCall.addLine.personResponsibilities.(!!org.kuali.rice.kew.rule.PersonRuleResponsibility!!).(:::;15;:::).anchor15"); 2865 waitForPageToLoad(); 2866 checkForIncidentReport(BLANKET_APPROVE_NAME); 2867 waitAndClickByName(BLANKET_APPROVE_NAME); 2868 waitForPageToLoad(); 2869 driver.switchTo().defaultContent(); //selectWindow("null"); 2870 Thread.sleep(2000); 2871 waitAndClickDocSearch(); 2872 waitForPageToLoad(); 2873 SeleneseTestBase.assertEquals("Kuali Portal Index", getTitle()); 2874 selectFrameIframePortlet(); 2875 waitAndClickSearch(); 2876 waitForPageToLoad(); 2877 SeleneseTestBase.assertTrue(isElementPresent(By.linkText(docId))); 2878 2879 if (isElementPresent(By.linkText(docId))) { 2880 assertEquals(DOC_STATUS_FINAL, getTextByXpath(DOC_STATUS_XPATH_2), "https://jira.kuali.org/browse/KULRICE-9051 WorkFlow Route Rules Blanket Approval submit status results in Enroute, not Final"); 2881 } else { 2882 SeleneseTestBase.assertEquals(docId, getTextByXpath(DOC_ID_XPATH_2)); 2883 SeleneseTestBase.assertEquals(DOC_STATUS_FINAL, getTextByXpath(DOC_STATUS_XPATH_2)); 2884 } 2885 } 2886 2887 protected void testCreateNewRRDTravelRequestDestRouting() throws Exception { 2888 selectFrameIframePortlet(); 2889 waitAndClick("img[alt=\"create new\"]"); 2890 waitForPageToLoad(); 2891 waitAndClickByName("methodToCall.performLookup.(!!org.kuali.rice.kew.rule.RuleBaseValues!!).(((id:parentRuleId))).((``)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;;::::).anchor"); 2892 waitForPageToLoad(); 2893 waitAndClickByXpath("//td[@class='infoline']/input[@name='methodToCall.search']"); 2894 waitForPageToLoad(); 2895 waitAndClick("a[title=\"return valueRule Id=1046 \"]"); 2896 waitForPageToLoad(); 2897 waitAndClickByName("parentResponsibilityId"); 2898 waitAndClickByName("methodToCall.createDelegateRule"); 2899 waitForPageToLoad(); 2900 Thread.sleep(3000); 2901 waitAndClickCancel(); 2902 waitForPageToLoad(); 2903 waitAndClickByName("methodToCall.processAnswer.button0"); 2904 waitForPageToLoad(); 2905 driver.switchTo().defaultContent(); 2906 waitAndClickByXpath("(//input[@name='imageField'])[2]"); 2907 waitForPageToLoad(); 2908 passed(); 2909 } 2910 2911 protected void testWorkFlowRouteRulesCreateNew() throws Exception { 2912 waitForPageToLoad(); 2913 Thread.sleep(5000); 2914 SeleneseTestBase.assertEquals("Kuali Portal Index", getTitle()); 2915 selectFrameIframePortlet(); 2916 waitAndClickCreateNew(); 2917 waitForPageToLoad(); 2918 Thread.sleep(3000); 2919 waitAndClickByName(CANCEL_NAME,"https://jira.kuali.org/browse/KULRICE-8161 Work Flow Route Rules cancel new yields 404 not found"); 2920 2921 // KULRICE-7753 : WorkFlowRouteRulesIT cancel confirmation missing from create new Route Rules. 2922 waitForPageToLoad(); 2923 Thread.sleep(3000); 2924 waitAndClickByName("methodToCall.processAnswer.button0", 2925 "https://jira.kuali.org/browse/KULRICE-7753 : WorkFlowRouteRulesIT cancel confirmation missing from create new Route Rules."); 2926 passed(); 2927 } 2928 2929 /** 2930 * tests that a Routing Rule maintenance document is created for an edit operation originating 2931 * from a lookup screen 2932 */ 2933 protected void testWorkFlowRouteRulesEditRouteRules() throws Exception { 2934 waitForPageToLoad(); 2935 SeleneseTestBase.assertEquals("Kuali Portal Index", getTitle()); 2936 selectFrameIframePortlet(); 2937 waitAndClickSearch(); 2938 waitAndClickEdit(); 2939 waitForPageToLoad(); 2940 selectFrameIframePortlet(); 2941 Thread.sleep(3000); 2942 waitAndClickCancel(); 2943 waitForPageToLoad(); 2944 Thread.sleep(3000); 2945 waitAndClickByName("methodToCall.processAnswer.button0"); 2946 passed(); 2947 } 2948 2949 protected String testCreateNewComponent(String componentName, String componentCode) throws Exception { 2950 return testCreateNewComponent(componentName, componentCode, ""); 2951 } 2952 2953 protected String testCreateNewComponent(String componentName, String componentCode, String message) throws Exception { 2954 waitForPageToLoad(); 2955 String docId = waitForDocId(); 2956 2957 //Enter details for Parameter. 2958 waitAndTypeByName("document.documentHeader.documentDescription", "Adding Test Component"); 2959 selectOptionByName("document.newMaintainableObject.namespaceCode", "KR-IDM"); 2960 waitAndTypeByName("document.newMaintainableObject.code", componentCode); 2961 waitAndTypeByName("document.newMaintainableObject.name", componentName); 2962 checkByName("document.newMaintainableObject.active"); 2963 waitAndClickSave(); 2964 waitAndClickSubmit(); 2965 waitForPageToLoad(); 2966 assertElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH, CREATE_NEW_DOCUMENT_NOT_SUBMITTED_SUCCESSFULLY_MESSAGE_TEXT + message); 2967 selectTopFrame(); 2968 waitAndClickDocSearchTitle(); 2969 waitForPageToLoad(); 2970 selectFrameIframePortlet(); 2971 waitAndClickSearch(); 2972 Thread.sleep(2000); 2973 SeleneseTestBase.assertEquals(docId, getTextByXpath(DOC_ID_XPATH_3)); 2974 SeleneseTestBase.assertEquals(DOC_STATUS_FINAL, getTextByXpath(DOC_STATUS_XPATH_2)); 2975 selectTopFrame(); 2976 return docId; 2977 } 2978 2979 2980 protected void testLookUpComponent(String docId, String componentName, String componentCode) throws Exception { 2981 selectFrameIframePortlet(); 2982 //Lookup 2983 waitAndTypeByName("name", componentName); 2984 waitAndClickSearch(); 2985 isElementPresentByLinkText(componentName); 2986 waitAndClickByLinkText(componentName); 2987 waitForPageToLoad(); 2988 Thread.sleep(2000); 2989 switchToWindow("Kuali :: Inquiry"); 2990 Thread.sleep(2000); 2991 SeleneseTestBase.assertEquals(componentName, getTextByXpath("//div[@class='tab-container']/table//span[@id='name.div']").trim()); 2992 SeleneseTestBase.assertEquals(componentCode, getTextByXpath("//div[@class='tab-container']/table//span[@id='code.div']").trim()); 2993 waitAndClickCloseWindow(); 2994 switchToWindow("null"); 2995 } 2996 2997 protected void testEditComponent(String docId, String componentName, String componentCode) throws Exception { 2998 selectFrameIframePortlet(); 2999 waitAndClickEdit(); 3000 waitForPageToLoad(); 3001 docId = waitForDocId(); 3002 waitAndTypeByName("document.documentHeader.documentDescription", "Editing Test Component"); 3003 clearTextByName("document.newMaintainableObject.name"); 3004 waitAndTypeByName("document.newMaintainableObject.name", componentName); 3005 waitAndClickSave(); 3006 waitAndClickSubmit(); 3007 waitForPageToLoad(); 3008 assertElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH,"Document is not submitted successfully"); 3009 selectTopFrame(); 3010 waitAndClickDocSearchTitle(); 3011 waitForPageToLoad(); 3012 selectFrameIframePortlet(); 3013 waitAndClickSearch(); 3014 Thread.sleep(2000); 3015 SeleneseTestBase.assertEquals(docId, getTextByXpath(DOC_ID_XPATH_3)); 3016 SeleneseTestBase.assertEquals(DOC_STATUS_FINAL, getTextByXpath(DOC_STATUS_XPATH_2)); 3017 selectTopFrame(); 3018 } 3019 3020 protected void testCopyComponent(String docId, String componentName, String componentCode) throws Exception { 3021 selectFrameIframePortlet(); 3022 waitAndClickCopy(); 3023 waitForPageToLoad(); 3024 docId = waitForDocId(); 3025 waitAndTypeByName("document.documentHeader.documentDescription", "Copying Test Component"); 3026 selectOptionByName("document.newMaintainableObject.namespaceCode", "KR-IDM"); 3027 waitAndTypeByName("document.newMaintainableObject.code", componentCode); 3028 clearTextByName("document.newMaintainableObject.name"); 3029 waitAndTypeByName("document.newMaintainableObject.name", componentName); 3030 waitAndClickSave(); 3031 waitAndClickSubmit(); 3032 waitForPageToLoad(); 3033 checkForDocError(); 3034 assertElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH,"Document is not submitted successfully"); 3035 selectTopFrame(); 3036 waitAndClickDocSearchTitle(); 3037 waitForPageToLoad(); 3038 selectFrameIframePortlet(); 3039 waitAndClickSearch(); 3040 Thread.sleep(2000); 3041 SeleneseTestBase.assertEquals(docId, getTextByXpath(DOC_ID_XPATH_3)); 3042 SeleneseTestBase.assertEquals(DOC_STATUS_FINAL, getTextByXpath(DOC_STATUS_XPATH_2)); 3043 selectTopFrame(); 3044 } 3045 3046 protected void testVerifyCopyComponent(String docId, String componentName, String componentCode) throws Exception { 3047 selectFrameIframePortlet(); 3048 waitAndTypeByName("name", componentName); 3049 waitAndClickSearch(); 3050 isElementPresentByLinkText(componentName); 3051 waitAndClickByLinkText(componentName); 3052 waitForPageToLoad(); 3053 Thread.sleep(2000); 3054 switchToWindow("Kuali :: Inquiry"); 3055 Thread.sleep(2000); 3056 SeleneseTestBase.assertEquals(componentName, getTextByXpath("//div[@class='tab-container']/table//span[@id='name.div']").trim()); 3057 SeleneseTestBase.assertEquals(componentCode, getTextByXpath("//div[@class='tab-container']/table//span[@id='code.div']").trim()); 3058 waitAndClickCloseWindow(); 3059 switchToWindow("null"); 3060 } 3061 3062 /** 3063 * Test the tooltip and external help on the page 3064 */ 3065 protected void testPageHelp() throws Exception { 3066 // test tooltip help 3067 fireMouseOverEventByXpath("//h2/span[@class='uif-headerText-span']"); 3068 SeleneseTestBase.assertEquals("Sample text for page help", getText("td.jquerybubblepopup-innerHtml")); 3069 3070 // test external help 3071 waitAndClickByXpath("//input[@alt='Help for Help Page']"); 3072 Thread.sleep(5000); 3073 switchToWindow("Kuali Foundation"); 3074 Thread.sleep(5000); 3075 switchToWindow(CONFIGURATION_VIEW_WINDOW_TITLE); 3076 } 3077 3078 /** 3079 * Test the tooltip help on the section and fields 3080 */ 3081 protected void testTooltipHelp() throws Exception { 3082 // verify that no tooltips are displayed initially 3083 if (isElementPresentByXpath("//td[contains(text(),'Sample text for section help - tooltip help')]")) { 3084 SeleneseTestBase.assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for section help - tooltip help')]")); 3085 } 3086 3087 if (isElementPresentByXpath("//td[contains(text(),'Sample text for field help - label left')]")) { 3088 SeleneseTestBase.assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for field help - label left')]")); 3089 } 3090 3091 if (isElementPresentByXpath("//td[contains(text(),'Sample text for field help - label right')]")) { 3092 SeleneseTestBase.assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for field help - label right')]")); 3093 } 3094 3095 if (isElementPresentByXpath("//td[contains(text(),'Sample text for field help - label top')]")) { 3096 SeleneseTestBase.assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for field help - label top')]")); 3097 } 3098 3099 if (isElementPresentByXpath("//td[contains(text(),'Sample text for standalone help widget tooltip which will never be rendered')]")) { 3100 SeleneseTestBase.assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for standalone help widget tooltip which will never be rendered')]")); 3101 } 3102 3103 if (isElementPresentByXpath("//td[contains(text(),'Sample text for field help - there is also a tooltip on the label but it is overridden by the help tooltip')]")) { 3104 SeleneseTestBase.assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for field help - there is also a tooltip on the label but it is overridden by the help tooltip')]")); 3105 } 3106 3107 if (isElementPresentByXpath("//td[contains(text(),'Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip')]")) { 3108 SeleneseTestBase.assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip')]")); 3109 } 3110 3111 if (isElementPresentByXpath("//td[contains(text(),'Sample text for field help - there is also an on-focus tooltip')]")) { 3112 SeleneseTestBase.assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for field help - there is also an on-focus tooltip')]")); 3113 } 3114 3115 if (isElementPresentByXpath("//td[contains(text(),'Sample text for on-focus event tooltip')]")) { 3116 SeleneseTestBase.assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for on-focus event tooltip')]")); 3117 } 3118 3119 if (isElementPresentByXpath("//td[contains(text(),'Sample text for check box help')]")) { 3120 SeleneseTestBase.assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for check box help')]")); 3121 } 3122 3123 // test tooltip help of section header 3124 fireMouseOverEventByXpath("//div[@id='ConfigurationTestView-Help-Section1']/div/h3[@class='uif-headerText']"); 3125 SeleneseTestBase.assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for section help - tooltip help')]")); 3126 String javascript="var element = document.getElementsByClassName('jquerybubblepopup jquerybubblepopup-black');" + "element[0].style.display='none'"; 3127 ((JavascriptExecutor) driver).executeScript(javascript); 3128 Thread.sleep(3000); 3129 SeleneseTestBase.assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for section help - tooltip help')]")); 3130 3131 // verify that no external help exist 3132 SeleneseTestBase.assertFalse(isElementPresent("#ConfigurationTestView-Help-Section1 input.uif-helpImage")); 3133 3134 // test tooltip help of field with label to the left 3135 fireMouseOverEventByXpath("//label[@id='field-label-left_label']"); 3136 Thread.sleep(3000); 3137 SeleneseTestBase.assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for field help - label left')]")); 3138 javascript="var element = document.getElementsByClassName('jquerybubblepopup jquerybubblepopup-black');" + 3139 "element[1].style.display='none'"; 3140 Thread.sleep(3000); 3141 ((JavascriptExecutor) driver).executeScript(javascript); 3142 SeleneseTestBase.assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for field help - label left')]")); 3143 3144 // test tooltip help of field with label to the right 3145 fireMouseOverEventByXpath("//label[@id='field-label-right_label']"); 3146 Thread.sleep(3000); 3147 SeleneseTestBase.assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for field help - label righ')]")); 3148 javascript="var element = document.getElementsByClassName('jquerybubblepopup jquerybubblepopup-black');" +"element[2].style.display='none'"; 3149 ((JavascriptExecutor) driver).executeScript(javascript); 3150 Thread.sleep(3000); 3151 SeleneseTestBase.assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for field help - label righ')]")); 3152 3153 // test tooltip help of field with label to the top 3154 fireMouseOverEventByXpath("//label[@id='field-label-top_label']"); 3155 Thread.sleep(3000); 3156 SeleneseTestBase.assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for field help - label top')]")); 3157 javascript="var element = document.getElementsByClassName('jquerybubblepopup jquerybubblepopup-black');" + "element[3].style.display='none'"; 3158 ((JavascriptExecutor) driver).executeScript(javascript); 3159 Thread.sleep(3000); 3160 SeleneseTestBase.assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for field help - label top')]")); 3161 3162 // verify that standalone help with tooltip is not rendered 3163 SeleneseTestBase.assertFalse(isElementPresentByXpath("//*[@id='standalone-help-not-rendered']")); 3164 3165 // test tooltip help when it overrides a tooltip 3166 fireMouseOverEventByXpath("//label[@id='override-tooltip_label']"); 3167 Thread.sleep(3000); 3168 SeleneseTestBase.assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for field help - there is also a tooltip on the label but it is overridden by the help tooltip')]")); 3169 if (isElementPresentByXpath("//td[contains(text(),'Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip')]")) { 3170 SeleneseTestBase.assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip')]")); 3171 } 3172 javascript="var element = document.getElementsByClassName('jquerybubblepopup jquerybubblepopup-black');" + "element[4].style.display='none'"; 3173 ((JavascriptExecutor) driver).executeScript(javascript); 3174 Thread.sleep(3000); 3175 SeleneseTestBase.assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for field help - there is also a tooltip on the label but it is overridden by the help tooltip')]")); 3176 3177 // test tooltip help in conjunction with a focus event tooltip 3178 fireMouseOverEventByXpath("//input[@id='on-focus-tooltip_control']"); 3179 SeleneseTestBase.assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for on-focus event tooltip')]")); 3180 fireMouseOverEventByXpath("//label[@id='on-focus-tooltip_label']"); 3181 SeleneseTestBase.assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for field help - there is also an on-focus tooltip')]")); 3182 javascript="var element = document.getElementsByClassName('jquerybubblepopup jquerybubblepopup-black');" +"element[5].style.display='none'"; 3183 ((JavascriptExecutor) driver).executeScript(javascript); 3184 Thread.sleep(3000); 3185 javascript="var element = document.getElementsByClassName('jquerybubblepopup jquerybubblepopup-black');" + "element[6].style.display='none'"; 3186 ((JavascriptExecutor) driver).executeScript(javascript); 3187 Thread.sleep(3000); 3188 SeleneseTestBase.assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for field help - there is also an on-focus tooltip')]")); 3189 SeleneseTestBase.assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for on-focus event tooltip')]")); 3190 3191 // test tooltip help against a check box - help contains html 3192 fireMouseOverEventByXpath("//label[@id='checkbox_label']"); 3193 SeleneseTestBase.assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for check box help')]")); 3194 javascript="var element = document.getElementsByClassName('jquerybubblepopup jquerybubblepopup-black');" + "element[7].style.display='none'"; 3195 ((JavascriptExecutor) driver).executeScript(javascript); 3196 Thread.sleep(3000); 3197 SeleneseTestBase.assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for check box help')]")); 3198 } 3199 3200 /** 3201 * Test the tooltip help on the sub-section and fields that are display only 3202 */ 3203 protected void testDisplayOnlyTooltipHelp() throws Exception { 3204 // verify that no tooltips are displayed initially 3205 if (isElementPresentByXpath("//td[contains(text(),'Sample text for sub-section help')]")) { 3206 SeleneseTestBase.assertFalse(isVisible("//td[contains(text(),'Sample text for sub-section help')]")); 3207 } 3208 3209 if (isElementPresentByXpath("//td[contains(text(),'Sample text for read only field help')]")) { 3210 SeleneseTestBase.assertFalse(isVisible("//td[contains(text(),'Sample text for read only field help')]")); 3211 } 3212 3213 // test tooltip help of sub-section header 3214 fireMouseOverEventByXpath("//span[contains(text(),'Display only fields')]"); 3215 SeleneseTestBase.assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for sub-section help')]")); 3216 String javascript="var element = document.getElementsByClassName('jquerybubblepopup jquerybubblepopup-black');" + 3217 "element[0].style.display='none'"; 3218 ((JavascriptExecutor) driver).executeScript(javascript); 3219 SeleneseTestBase.assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for sub-section help')]")); 3220 3221 // test tooltip help of display only data field 3222 fireMouseOverEventByXpath("//label[@for='display-field_control']"); 3223 SeleneseTestBase.assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for read only field help')]")); 3224 javascript="var element = document.getElementsByClassName('jquerybubblepopup jquerybubblepopup-black');" + 3225 "element[0].style.display='none'"; 3226 ((JavascriptExecutor) driver).executeScript(javascript); 3227 } 3228 3229 /** 3230 * Test the tooltip help on the section and fields with no content 3231 */ 3232 protected void testMissingTooltipHelp() throws Exception { 3233 // verify that no tooltips are displayed initially 3234 SeleneseTestBase.assertFalse(isElementPresentByXpath("//*[@class='jquerybubblepopup jquerybubblepopup-black']")); 3235 3236 // verify that no external help exist 3237 SeleneseTestBase.assertFalse(isElementPresent("#ConfigurationTestView-Help-Section2 input.uif-helpImage")); 3238 3239 // test tooltip help of section header 3240 fireMouseOverEventByXpath("//div[@id='ConfigurationTestView-Help-Section2']/div"); 3241 SeleneseTestBase.assertFalse(isElementPresentByXpath("//*[@class='jquerybubblepopup jquerybubblepopup-black']")); 3242 SeleneseTestBase.assertFalse(isElementPresentByXpath("//*[@class='jquerybubblepopup jquerybubblepopup-black']")); 3243 3244 // test tooltip help of field 3245 fireMouseOverEventByXpath("//label[@id='missing-tooltip-help_label']"); 3246 SeleneseTestBase.assertFalse(isElementPresentByXpath("//*[@class='jquerybubblepopup jquerybubblepopup-black']")); 3247 SeleneseTestBase.assertFalse(isElementPresentByXpath("//*[@class='jquerybubblepopup jquerybubblepopup-black']")); 3248 } 3249 3250 /** 3251 * Test the external help on the section and fields 3252 */ 3253 3254 protected void testExternalHelp2() throws Exception { 3255 // test external help of section 3256 assertPopUpWindowUrl(By.cssSelector("input[title=\"Help for External Help\"]"), "HelpWindow", "http://www.kuali.org/?section"); 3257 3258 // test external help of field with label left 3259 assertPopUpWindowUrl(By.xpath("//div[@id='field-label-left-external-help']/fieldset/input[@title='Help for Field Label']"), "HelpWindow", 3260 "http://www.kuali.org/?label_left"); 3261 3262 // test external help of field with label right 3263 assertPopUpWindowUrl(By.xpath("//div[@id='field-label-right-external-help']/fieldset/input[@title='Help for Field Label']"), "HelpWindow", 3264 "http://www.kuali.org/?label_right"); 3265 3266 // test external help of field with label top and help URL from system parameters 3267 assertPopUpWindowUrl(By.xpath("//div[@id='field-label-top-external-help']/fieldset/input[@title='Help for Field Label']"), "HelpWindow", 3268 "http://www.kuali.org/?system_parm"); 3269 3270 // test external help of standalone help widget 3271 assertPopUpWindowUrl(By.id("standalone-external-help"), "HelpWindow", "http://www.kuali.org/?widget_only"); 3272 } 3273 3274 /** 3275 * Test the external help on the sub-section and display only fields 3276 */ 3277 3278 protected void testDisplayOnlyExternalHelp2() throws Exception { 3279 // test external help of sub-section 3280 assertPopUpWindowUrl(By.cssSelector("input[title=\"Help for Display only fields\"]"), "HelpWindow", "http://www.kuali.org/?sub_section"); 3281 3282 // test external help of display only data field 3283 assertPopUpWindowUrl(By.xpath("//div[@id='display-field-external-help']/fieldset/input[@title='Help for Field Label']"), "HelpWindow", 3284 "http://www.kuali.org/?display_field"); 3285 } 3286 3287 /** 3288 * Test the external help on the section and fields with missing help URL 3289 */ 3290 3291 protected void testMissingExternalHelp2() throws Exception { 3292 // test external help of section is not rendered 3293 SeleneseTestBase.assertFalse(isElementPresent(By.cssSelector("input[title=\"Help for Missing External Help\"]"))); 3294 3295 // test external help of field with blank externalHelpURL is not rendered 3296 SeleneseTestBase.assertFalse(isElementPresentByXpath("//div[@id='external-help-externalHelpUrl-empty']/*[@class='uif-helpImage']")); 3297 3298 // test external help of field with empty helpDefinition is not rendered 3299 SeleneseTestBase.assertFalse(isElementPresentByXpath("//div[@id='external-help-helpdefinition-empty']/*[@class='uif-helpImage']")); 3300 3301 // test external help of field with missing system parameter is not rendered 3302 SeleneseTestBase.assertFalse(isElementPresentByXpath("//div[@id='external-help-system-parm-missing']/*[@class='uif-helpImage']")); 3303 3304 // test external help of standalone help widget is not rendered 3305 SeleneseTestBase.assertFalse(isElementPresentByXpath("//div[@id='standalone-external-help-missing']")); 3306 } 3307 3308 protected void testReferenceCampusTypeBlanketApprove() throws Exception { 3309 selectFrameIframePortlet(); 3310 waitAndCreateNew(); 3311 String docId = waitForDocId(); 3312 assertBlanketApproveButtonsPresent(); 3313 String dtsTwo = ITUtil.createUniqueDtsPlusTwoRandomCharsNot9Digits(); 3314 waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Validation Test Campus Type " + dtsTwo); 3315 waitAndTypeByXpath(DOC_CODE_XPATH, RandomStringUtils.randomAlphabetic(1)); 3316 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", "Indianapolis" + dtsTwo); 3317 int attemptCount = 1; 3318 while (hasDocError("same primary key already exists") && attemptCount < 25) { 3319 clearTextByXpath(DOC_CODE_XPATH); 3320 waitAndTypeByXpath(DOC_CODE_XPATH, Character.toString((char) ('A' + attemptCount++))); 3321 } 3322 blanketApproveTest(); 3323 assertDocFinal(docId); 3324 } 3325 3326 protected void testSearchEditCancel() throws InterruptedException { 3327 selectFrameIframePortlet(); 3328 waitAndClickSearch2(); 3329 waitAndClickEdit(); 3330 testCancelConfirmation(); 3331 } 3332 3333 protected void testServerErrorsIT() throws Exception { 3334 waitAndClickByXpath("//button[contains(.,'Get Error Messages')]"); 3335 waitForPageToLoad(); 3336 Thread.sleep(5000); 3337 assertElementPresent("div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-errorMessageItem"); 3338 waitIsVisibleByXpath("//div[@data-header_for='Demo-ValidationLayout-Section1']"); 3339 assertElementPresentByXpath("//*[@data-messageitemfor='Demo-ValidationLayout-Section1' and @class='uif-errorMessageItem']"); 3340 assertElementPresent("div[data-role=\"InputField\"] img[alt=\"Error\"]"); 3341 assertElementPresentByXpath("//a[contains(.,'Section 1 Title')]"); 3342 fireMouseOverEventByXpath("//a[contains(.,'Field 1')]"); 3343 assertElementPresent(".uif-errorMessageItem-field"); 3344 waitAndClickByXpath("//a[contains(.,'Field 1')]"); 3345 Thread.sleep(2000); 3346 waitIsVisible(".jquerybubblepopup-innerHtml"); 3347 waitIsVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems"); 3348 waitIsVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-errorMessageItem-field"); 3349 waitAndTypeByName("field1", ""); 3350 fireEvent("field1", "blur"); 3351 fireEvent("field1", "focus"); 3352 waitIsVisible(".jquerybubblepopup-innerHtml"); 3353 waitIsVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-errorMessageItem-field"); 3354 waitIsVisible(".jquerybubblepopup-innerHtml > .uif-clientMessageItems"); 3355 waitIsVisible(".jquerybubblepopup-innerHtml > .uif-clientMessageItems .uif-errorMessageItem-field"); 3356 waitAndTypeByName("field1", "t"); 3357 3358 for (int second = 0;; second++) { 3359 if (second >= waitSeconds) { 3360 failableFail(TIMEOUT_MESSAGE); 3361 } 3362 try { 3363 if (!isElementPresent(".jquerybubblepopup-innerHtml > .uif-clientMessageItems")) { 3364 break; 3365 } 3366 } catch (Exception e) {} 3367 Thread.sleep(1000); 3368 } 3369 3370 waitIsVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-errorMessageItem-field"); 3371 SeleneseTestBase.assertFalse(isElementPresent(".jquerybubblepopup-innerHtml > .uif-clientMessageItems")); 3372 } 3373 3374 protected void testServerInfoIT() throws Exception { 3375 waitAndClickByXpath("//button[contains(.,'Get Info Messages')]"); 3376 waitIsVisibleByXpath("//div[@data-messagesfor='Demo-ValidationLayout-SectionsPage']"); 3377 SeleneseTestBase.assertTrue(isVisibleByXpath("//div[@data-messagesfor='Demo-ValidationLayout-SectionsPage']")); 3378 SeleneseTestBase.assertTrue(isElementPresent("div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-infoMessageItem")); 3379 SeleneseTestBase.assertTrue(isVisible("div[data-messagesfor=\"Demo-ValidationLayout-Section1\"]")); 3380 SeleneseTestBase.assertTrue(isElementPresent("div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] .uif-infoMessageItem")); 3381 SeleneseTestBase.assertTrue(isElementPresentByXpath("//div[@data-role='InputField']//img[@alt='Information']")); 3382 fireMouseOverEventByXpath("//a[contains(.,'Field 1')]"); 3383 SeleneseTestBase.assertTrue(isElementPresent(".uif-infoHighlight")); 3384 waitAndClickByXpath("//a[contains(.,'Field 1')]"); 3385 3386 for (int second = 0;; second++) { 3387 if (second >= waitSeconds) 3388 failableFail(TIMEOUT_MESSAGE); 3389 try { 3390 if (isVisible(".jquerybubblepopup-innerHtml")) 3391 break; 3392 } catch (Exception e) {} 3393 Thread.sleep(1000); 3394 } 3395 3396 SeleneseTestBase.assertTrue(isVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems")); 3397 SeleneseTestBase.assertTrue(isVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-infoMessageItem-field")); 3398 waitAndTypeByName("field1", ""); 3399 fireEvent("field1", "blur"); 3400 fireEvent("field1", "focus"); 3401 3402 for (int second = 0;; second++) { 3403 if (second >= waitSeconds) 3404 failableFail(TIMEOUT_MESSAGE); 3405 try { 3406 if (isVisible(".jquerybubblepopup-innerHtml")) 3407 break; 3408 } catch (Exception e) {} 3409 Thread.sleep(1000); 3410 } 3411 3412 SeleneseTestBase.assertTrue(isVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-infoMessageItem-field")); 3413 for (int second = 0;; second++) { 3414 if (second >= waitSeconds) 3415 failableFail(TIMEOUT_MESSAGE); 3416 try { 3417 if (isVisible(".jquerybubblepopup-innerHtml > .uif-clientMessageItems")) 3418 break; 3419 } catch (Exception e) {} 3420 Thread.sleep(1000); 3421 } 3422 3423 SeleneseTestBase.assertTrue(isVisible(".jquerybubblepopup-innerHtml > .uif-clientMessageItems .uif-errorMessageItem-field")); 3424 waitAndTypeByName("field1", "b"); 3425 fireEvent("field1", "blur"); 3426 fireEvent("field1", "focus"); 3427 3428 for (int second = 0;; second++) { 3429 if (second >= waitSeconds) 3430 failableFail(TIMEOUT_MESSAGE); 3431 try { 3432 if (!isElementPresent(".jquerybubblepopup-innerHtml > .uif-clientMessageItems")) 3433 break; 3434 } catch (Exception e) {} 3435 Thread.sleep(1000); 3436 } 3437 3438 fireEvent("field1", "blur"); 3439 Thread.sleep(3000); 3440 SeleneseTestBase.assertTrue(!isVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-infoMessageItem-field")); 3441 SeleneseTestBase.assertFalse(isElementPresent(".jquerybubblepopup-innerHtml > .uif-clientMessageItems")); 3442 fireEvent("field1", "focus"); 3443 clearTextByName("field1"); 3444 fireEvent("field1", "blur"); 3445 SeleneseTestBase.assertTrue(isElementPresent("div.uif-hasError")); 3446 SeleneseTestBase.assertTrue(isElementPresent("img[src*=\"error.png\"]")); 3447 } 3448 3449 protected void testServerWarningsIT() throws Exception { 3450 waitAndClickByXpath("//button[contains(.,'Get Warning Messages')]"); 3451 waitForPageToLoad(); 3452 Thread.sleep(3000); 3453 com.thoughtworks.selenium.SeleneseTestBase.assertTrue("div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] not visible", 3454 isVisible("div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"]")); 3455 com.thoughtworks.selenium.SeleneseTestBase.assertTrue( 3456 "div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-warningMessageItem not present", 3457 isElementPresent("div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-warningMessageItem")); 3458 com.thoughtworks.selenium.SeleneseTestBase.assertTrue( 3459 "div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] not visible", isVisible( 3460 "div[data-messagesfor=\"Demo-ValidationLayout-Section1\"]")); 3461 com.thoughtworks.selenium.SeleneseTestBase.assertTrue( 3462 "div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] .uif-warningMessageItem not present", 3463 isElementPresent("div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] .uif-warningMessageItem")); 3464 com.thoughtworks.selenium.SeleneseTestBase.assertTrue( 3465 "div[data-role=\"InputField\"] img[alt=\"Warning\"] not present", isElementPresent( 3466 "div[data-role=\"InputField\"] img[alt=\"Warning\"]")); 3467 fireMouseOverEvent(By.xpath("//a[contains(.,'Field 1')]")); 3468 com.thoughtworks.selenium.SeleneseTestBase.assertTrue( 3469 ".uif-warningHighlight no present when //a[contains(.,'Field 1')] is moused over", 3470 isElementPresent(".uif-warningHighlight")); 3471 waitAndClickByXpath("//a[contains(.,'Field 1')]"); 3472 waitForElementVisible(".jquerybubblepopup-innerHtml", " after click on //a[contains(.,'Field 1')]"); 3473 com.thoughtworks.selenium.SeleneseTestBase.assertTrue( 3474 ".jquerybubblepopup-innerHtml > .uif-serverMessageItems not visible", isVisible( 3475 ".jquerybubblepopup-innerHtml > .uif-serverMessageItems")); 3476 com.thoughtworks.selenium.SeleneseTestBase.assertTrue( 3477 ".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field not visible", 3478 isVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field")); 3479 waitAndTypeByName("field1", ""); 3480 fireEvent("field1", "blur"); 3481 fireMouseOverEventByName("field1"); 3482 waitForElementVisible(".jquerybubblepopup-innerHtml", 3483 " not visible after typing nothing in name=field1 then firing blur and focus events"); 3484 com.thoughtworks.selenium.SeleneseTestBase.assertTrue( 3485 ".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field not visible after typing nothing in name=field1 then firing blur and focus events", 3486 isVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field")); 3487 waitForElementVisible(".jquerybubblepopup-innerHtml> .uif-clientMessageItems", 3488 " not visible after typing nothing in name=field1 then firing blur and focus events"); 3489 com.thoughtworks.selenium.SeleneseTestBase.assertTrue( 3490 ".jquerybubblepopup-innerHtml > .uif-clientMessageItems .uif-errorMessageItem-field not visible after typing nothing in name=field1 then firing blur and focus events", 3491 isVisible(".jquerybubblepopup-innerHtml > .uif-clientMessageItems .uif-errorMessageItem-field")); 3492 waitAndTypeByName("field1", "b"); 3493 fireEvent("field1", "blur"); 3494 fireMouseOverEventByName("field1"); 3495 waitForElementVisible(".jquerybubblepopup-innerHtml> .uif-serverMessageItems", ""); 3496 com.thoughtworks.selenium.SeleneseTestBase.assertTrue( 3497 ".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field not visible after typing b in name=field1 then firing blur and focus events", 3498 isVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field")); 3499 com.thoughtworks.selenium.SeleneseTestBase.assertTrue(".jquerybubblepopup-innerHtml > .uif-clientMessageItems", 3500 !isElementPresent( 3501 ".jquerybubblepopup-innerHtml > .uif-clientMessageItems")); 3502 clearTextByName("field1"); 3503 fireEvent("field1", "blur"); 3504 fireMouseOverEventByName("field1"); 3505 com.thoughtworks.selenium.SeleneseTestBase.assertTrue( 3506 ".uif-hasError is not present after typing nothing in name=field1 and then firing focus and blur events", 3507 isElementPresent(".uif-hasError")); 3508 com.thoughtworks.selenium.SeleneseTestBase.assertTrue( 3509 "img[src*=\"error.png\"] is not present after typing nothing in name=field1 and then firing focus and blur events", 3510 isElementPresent("img[src*=\"error.png\"]")); 3511 passed(); 3512 } 3513 3514 /** 3515 * Test the tooltip and external help on the view 3516 */ 3517 protected void testViewHelp() throws Exception { 3518 // test tooltip help 3519 fireMouseOverEventByXpath("//h1/span[@class='uif-headerText-span']"); 3520 SeleneseTestBase.assertEquals("Sample text for view help", getText("td.jquerybubblepopup-innerHtml")); 3521 3522 // test external help 3523 waitAndClickByXpath("//input[@alt='Help for Configuration Test View - Help']"); 3524 Thread.sleep(5000); 3525 switchToWindow("Kuali Foundation"); 3526 Thread.sleep(5000); 3527 switchToWindow(CONFIGURATION_VIEW_WINDOW_TITLE); 3528 } 3529 3530 /** 3531 * Test the tooltip and external help on the view 3532 */ 3533 protected void testViewHelp2() throws Exception { 3534 // test tooltip help 3535 if (isElementPresentByXpath("//td[@class='jquerybubblepopup-innerHtml']")) { 3536 SeleneseTestBase.assertFalse(driver.findElement(By.cssSelector("td.jquerybubblepopup-innerHtml")).isDisplayed()); 3537 } 3538 3539 // test tooltip help 3540 fireMouseOverEventByXpath("//h1/span[@class='uif-headerText-span']"); 3541 Thread.sleep(2000); 3542 SeleneseTestBase.assertTrue(isVisibleByXpath("//td[contains(text(),'View help')]")); 3543 assertPopUpWindowUrl(By.cssSelector("input[title=\"Help for Configuration Test View\"]"), "HelpWindow", "http://www.kuali.org/"); 3544 } 3545 3546 protected void testVerifyAddDeleteFiscalOfficerLegacy() throws Exception { 3547 selectFrameIframePortlet(); 3548 checkForIncidentReport("testVerifyAddDeleteFiscalOfficerLegacy"); 3549 waitAndTypeByName("document.documentHeader.documentDescription", ITUtil.createUniqueDtsPlusTwoRandomChars()); 3550 waitAndTypeByName("newCollectionLines['document.newMaintainableObject.dataObject.fiscalOfficer.accounts'].number","1234567890"); 3551 waitAndTypeByName("newCollectionLines['document.newMaintainableObject.dataObject.fiscalOfficer.accounts'].foId", "2"); 3552 waitAndClickByXpath("//button[@data-loadingmessage='Adding Line...']"); 3553 waitForElementPresentByName("document.newMaintainableObject.dataObject.fiscalOfficer.accounts[0].number"); 3554 SeleneseTestBase.assertEquals("1234567890", getAttributeByName( 3555 "document.newMaintainableObject.dataObject.fiscalOfficer.accounts[0].number", "value")); 3556 SeleneseTestBase.assertEquals("2", getAttributeByName( 3557 "document.newMaintainableObject.dataObject.fiscalOfficer.accounts[0].foId", "value")); 3558 waitAndClickByXpath("//button[@data-loadingmessage='Deleting Line...']"); 3559 Thread.sleep(3000); 3560 SeleneseTestBase.assertEquals(Boolean.FALSE, (Boolean) isElementPresentByName( 3561 "document.newMaintainableObject.dataObject.fiscalOfficer.accounts[0].number")); 3562 passed(); 3563 } 3564 3565 protected void testVerifyAddDeleteNoteLegacy() throws Exception { 3566 selectFrameIframePortlet(); 3567 waitAndClick("div.tableborders.wrap.uif-boxLayoutVerticalItem.clearfix span.uif-headerText-span > img.uif-disclosure-image"); 3568 waitForElementPresent("button[title='Add a Note'].uif-action.uif-primaryActionButton.uif-smallActionButton"); 3569 waitAndClickByName("newCollectionLines['document.notes'].noteText"); 3570 waitAndTypeByName("newCollectionLines['document.notes'].noteText", "Test note"); 3571 waitAndClick("button[title='Add a Note'].uif-action.uif-primaryActionButton.uif-smallActionButton"); 3572 // waitForElementPresentByName("document.notes[0].noteText"); 3573 SeleneseTestBase.assertEquals("Test note", getTextByXpath("//pre")); 3574 waitAndClick("button[title='Delete a Note'].uif-action.uif-primaryActionButton.uif-smallActionButton"); 3575 SeleneseTestBase.assertEquals(Boolean.FALSE, (Boolean) isElementPresentByName("document.notes[0].noteText")); 3576 passed(); 3577 } 3578 3579 protected void testVerifyAdHocRecipientsLegacy() throws Exception { 3580 selectFrameIframePortlet(); 3581 waitAndClickByLinkText("Fiscal Officer Accounts"); 3582 assertElementPresentByXpath( 3583 "//select[@name=\"newCollectionLines['document.adHocRoutePersons'].actionRequested\"]"); 3584 assertElementPresentByXpath( 3585 "//input[@name=\"newCollectionLines['document.adHocRoutePersons'].name\" and @type=\"text\"]"); 3586 assertElementPresentByXpath( 3587 "//select[@name=\"newCollectionLines['document.adHocRouteWorkgroups'].actionRequested\"]"); 3588 assertElementPresentByXpath( 3589 "//input[@name=\"newCollectionLines['document.adHocRouteWorkgroups'].recipientNamespaceCode\" and @type='text']"); 3590 assertElementPresentByXpath( 3591 "//input[@name=\"newCollectionLines['document.adHocRouteWorkgroups'].recipientName\" and @type='text']"); 3592 passed(); 3593 } 3594 3595 protected void testVerifyButtonsLegacy() throws Exception { 3596 selectFrameIframePortlet(); 3597 assertElementPresentByXpath("//button[contains(.,'ubmit')]"); 3598 assertElementPresentByXpath("//button[contains(.,'ave')]"); 3599 assertElementPresentByXpath("//button[contains(.,'lanket approve')]"); 3600 assertElementPresentByXpath("//button[contains(.,'lose')]"); 3601 assertElementPresentByXpath("//a[contains(.,'ancel')]"); 3602 passed(); 3603 } 3604 3605 protected void testVerifyConstraintText() throws Exception { 3606 selectFrameIframePortlet(); 3607 SeleneseTestBase.assertEquals("* indicates required field", getText( 3608 "div.uif-boxLayout.uif-horizontalBoxLayout.clearfix > span.uif-message.uif-requiredInstructionsMessage.uif-boxLayoutHorizontalItem")); 3609 SeleneseTestBase.assertEquals("Must not be more than 10 characters", getText( 3610 "div.uif-group.uif-gridGroup.uif-gridSection.uif-disclosure.uif-boxLayoutVerticalItem.clearfix div[data-label='Travel Account Number'].uif-field.uif-inputField span.uif-message.uif-constraintMessage")); 3611 SeleneseTestBase.assertEquals("Must not be more than 10 characters", getText( 3612 "div.uif-group.uif-gridGroup.uif-gridSection.uif-disclosure.uif-boxLayoutVerticalItem.clearfix div[data-label='Travel Sub Account Number'].uif-field.uif-inputField span.uif-message.uif-constraintMessage")); 3613 SeleneseTestBase.assertEquals("Must not be more than 10 characters", getText( 3614 "div.uif-group.uif-gridGroup.uif-collectionItem.uif-gridCollectionItem.uif-collectionAddItem div[data-label='Travel Account Number'].uif-field.uif-inputField span.uif-message.uif-constraintMessage")); 3615 passed(); 3616 } 3617 3618 protected void testVerifyEditedComponent(String docId, String componentName, String componentCode) throws Exception { 3619 selectFrameIframePortlet(); 3620 waitAndTypeByName("name", componentName); 3621 waitAndClickSearch(); 3622 isElementPresentByLinkText(componentName); 3623 waitAndClickByLinkText(componentName); 3624 waitForPageToLoad(); 3625 Thread.sleep(2000); 3626 switchToWindow("Kuali :: Inquiry"); 3627 Thread.sleep(2000); 3628 SeleneseTestBase.assertEquals(componentName, getTextByXpath("//div[@class='tab-container']/table//span[@id='name.div']").trim()); 3629 SeleneseTestBase.assertEquals(componentCode, getTextByXpath("//div[@class='tab-container']/table//span[@id='code.div']").trim()); 3630 waitAndClickCloseWindow(); 3631 switchToWindow("null"); 3632 List<String> parameterList=new ArrayList<String>(); 3633 } 3634 3635 protected void testVerifyDisclosures() throws Exception { 3636 selectFrameIframePortlet(); 3637 assertElementPresentByXpath("//span[contains(text(),'Document Overview')]"); 3638 assertElementPresentByXpath("//span[contains(text(),'Document Overview')]"); 3639 assertElementPresentByXpath("//span[contains(text(),'Account Information')]"); 3640 assertElementPresentByXpath("//span[contains(text(),'Fiscal Officer Accounts')]"); 3641 assertElementPresentByXpath("//span[contains(text(),'Notes and Attachments')]"); 3642 assertElementPresentByXpath("//span[contains(text(),'Ad Hoc Recipients')]"); 3643 assertElementPresentByXpath("//span[contains(text(),'Route Log')]"); 3644 colapseExpandByXpath("//span[contains(text(),'Document Overview')]//img", "//label[contains(text(),'Organization Document Number')]"); 3645 colapseExpandByXpath("//span[contains(text(),'Account Information')]//img","//label[contains(text(),'Travel Account Type Code')]"); 3646 colapseExpandByXpath("//span[contains(text(),'Fiscal Officer Accounts')]//img","//a[contains(text(),'Lookup/Add Multiple Lines')]"); 3647 expandColapseByXpath("//span[contains(text(),'Notes and Attachments')]//img","//label[contains(text(),'Note Text')]"); 3648 expandColapseByXpath("//span[contains(text(),'Ad Hoc Recipients')]","//span[contains(text(),'Ad Hoc Group Requests')]"); 3649 3650 // Handle frames 3651 waitAndClickByXpath("//span[contains(text(),'Route Log')]//img"); 3652 selectFrame("routeLogIFrame"); 3653 waitIsVisibleByXpath("//img[@alt='refresh']"); 3654 3655 // relative=top iframeportlet might look weird but either alone results in something not found. 3656 selectTopFrame(); 3657 selectFrameIframePortlet(); 3658 waitAndClickByXpath("//span[contains(text(),'Route Log')]//img"); 3659 selectFrame("routeLogIFrame"); 3660 waitNotVisibleByXpath("//img[@alt='refresh']"); 3661 passed(); 3662 } 3663 3664 protected void testVerifyDocumentOverviewLegacy() throws Exception { 3665 selectFrameIframePortlet(); 3666 assertTextPresent("Document Overview"); 3667 assertElementPresentByXpath("//input[@name='document.documentHeader.documentDescription']"); 3668 assertElementPresentByXpath("//input[@name='document.documentHeader.organizationDocumentNumber']"); 3669 assertElementPresentByXpath("//textarea[@name='document.documentHeader.explanation']"); 3670 passed(); 3671 } 3672 3673 protected void testVerifyExpandCollapse() throws Exception { 3674 selectFrameIframePortlet(); 3675 assertElementPresentByXpath("//button[contains(@class, 'uif-expandDisclosuresButton')]"); 3676 assertElementPresentByXpath("//button[contains(@class, 'uif-collapseDisclosuresButton')]"); 3677 passed(); 3678 } 3679 3680 protected void testVerifyFieldsLegacy() throws Exception { 3681 selectFrameIframePortlet(); 3682 assertElementPresentByXpath("//input[@name='document.newMaintainableObject.dataObject.number' and @type='text' and @size=10 and @maxlength=10]"); 3683 assertElementPresentByXpath("//input[@name='document.newMaintainableObject.dataObject.extension.accountTypeCode' and @type='text' and @size=2 and @maxlength=3]"); 3684 assertElementPresentByXpath( 3685 "//input[@name='document.newMaintainableObject.dataObject.subAccount' and @type='text' and @size=10 and @maxlength=10]"); 3686 assertElementPresentByXpath("//input[@name='document.newMaintainableObject.dataObject.subsidizedPercent' and @type='text' and @size=6 and @maxlength=20]"); 3687 assertElementPresentByXpath( 3688 "//input[@name='document.newMaintainableObject.dataObject.foId' and @type='text' and @size=5 and @maxlength=10]"); 3689 assertElementPresentByXpath( 3690 "//input[@name=\"newCollectionLines['document.newMaintainableObject.dataObject.fiscalOfficer.accounts'].number\" and @type='text' and @size=10 and @maxlength=10]"); 3691 assertElementPresentByXpath( 3692 "//input[@name=\"newCollectionLines['document.newMaintainableObject.dataObject.fiscalOfficer.accounts'].foId\" and @type='text' and @size=5 and @maxlength=10]"); 3693 passed(); 3694 } 3695 3696 protected void testVerifyHeaderFieldsLegacy() throws Exception { 3697 selectFrameIframePortlet(); 3698 assertElementPresentByXpath("//div[contains(@class, 'uif-documentNumber')]"); 3699 assertElementPresentByXpath("//div[contains(@class, 'uif-documentInitiatorNetworkId')]"); 3700 assertElementPresentByXpath("//div[contains(@class, 'uif-documentStatus')]"); 3701 assertElementPresentByXpath("//div[contains(@class, 'uif-documentCreateDate')]"); 3702 passed(); 3703 } 3704 3705 protected void testVerifyLookupAddMultipleLinesLegacy() throws Exception { 3706 selectFrameIframePortlet(); 3707 assertElementPresentByXpath("//a[contains(text(),'Lookup/Add Multiple Lines')]"); 3708 passed(); 3709 } 3710 3711 protected void testVerifyNotesAndAttachments() throws Exception { 3712 selectFrameIframePortlet(); 3713 waitAndClickByXpath("//span[contains(text(),'Notes and Attachments')]"); 3714 waitForElementPresentByXpath("//button[@title='Add a Note']"); 3715 assertElementPresentByXpath("//span[contains(text(),'Notes and Attachments')]"); 3716 assertElementPresentByXpath("//textarea[@name=\"newCollectionLines['document.notes'].noteText\"]"); 3717 assertElementPresentByXpath("//input[@name='attachmentFile']"); 3718 3719 //assertElementPresentByXpath("//input[@name=\"newCollectionLines['document.notes'].attachment.attachmentTypeCode\"]"); 3720 passed(); 3721 } 3722 3723 protected void testVerifyQuickfinderIconsLegacy() throws Exception { 3724 selectFrameIframePortlet(); 3725 assertTextPresent("Document Overview"); 3726 assertElementPresentByXpath("//*[@id='quickfinder1']"); 3727 assertElementPresentByXpath("//*[@id='quickfinder2']"); 3728 assertElementPresentByXpath("//*[@id='quickfinder3']"); 3729 assertElementPresentByXpath("//*[@id='quickfinder4_add']"); 3730 3731 // TODO it would be better to test that the image isn't 404 3732 passed(); 3733 } 3734 3735 protected void testVerifyRouteLog() throws Exception { 3736 selectFrameIframePortlet(); 3737 waitAndClickByLinkText("Route Log"); 3738 waitForElementPresent("//iframe[contains(@src,'RouteLog.do')]"); 3739 passed(); 3740 } 3741 3742 protected void testVerifySave() throws Exception { 3743 selectFrameIframePortlet(); 3744 waitAndTypeByName("document.documentHeader.documentDescription", "Test Document " + ITUtil.DTS); 3745 waitAndClickByName("document.newMaintainableObject.dataObject.number"); 3746 waitAndTypeByName("document.newMaintainableObject.dataObject.number", "1234567890"); 3747 waitAndTypeByName("document.newMaintainableObject.dataObject.extension.accountTypeCode", "EAT"); 3748 waitAndTypeByName("document.newMaintainableObject.dataObject.subAccount", "a1"); 3749 waitAndClick( 3750 "button[data-loadingmessage='Saving...'].uif-action.uif-primaryActionButton.uif-boxLayoutHorizontalItem"); 3751 Thread.sleep(2000); 3752 3753 // checkErrorMessageItem(" also digit validation jira https://jira.kuali.org/browse/KULRICE-8038"); 3754 passed(); 3755 } 3756 3757 protected void testVerifySubsidizedPercentWatermarkLegacy() throws Exception { 3758 selectFrameIframePortlet(); 3759 3760 // May be blowing up due to multiple locators 3761 //assertTrue(isElementPresent("//input[@name='document.newMaintainableObject.dataObject.subsidizedPercent' and @type='text' and @placeholder='##.## ']")); 3762 assertElementPresentByXpath("//input[@name='document.newMaintainableObject.dataObject.subsidizedPercent']"); 3763 passed(); 3764 } 3765 3766 protected void testWorkFlowDocTypeBlanketApprove() throws Exception { 3767 selectFrameIframePortlet(); 3768 waitAndCreateNew(); 3769 String docId = waitForDocId(); 3770 assertBlanketApproveButtonsPresent(); 3771 waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Validation Test Document Type " + ITUtil.createUniqueDtsPlusTwoRandomCharsNot9Digits()); 3772 String parentDocType = "//input[@name='methodToCall.performLookup.(!!org.kuali.rice.kew.doctype.bo.DocumentType!!).(((name:document.newMaintainableObject.parentDocType.name,documentTypeId:document.newMaintainableObject.docTypeParentId,))).((`document.newMaintainableObject.parentDocType.name:name,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" 3773 + getBaseUrlString() + "/kr/lookup.do;::::).anchor4']"; 3774 waitAndClickByXpath(parentDocType); 3775 waitAndClickSearch(); 3776 waitAndClickReturnValue(); 3777 String docTypeName = "DocType" + ITUtil.DTS; 3778 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", docTypeName); 3779 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.unresolvedDocHandlerUrl']", 3780 "${kr.url}/maintenance.do?methodToCall=docHandler"); 3781 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.label']", 3782 "Workflow Maintenance Document Type Document"); 3783 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.unresolvedHelpDefinitionUrl']", 3784 "default.htm?turl=WordDocuments%2Fdocumenttype.htm"); 3785 blanketApproveTest(); 3786 assertDocFinal(docId); 3787 } 3788 3789 protected void uncheck(By by) throws InterruptedException { 3790 WebElement element = driver.findElement(by); 3791 if (element.isSelected()) { 3792 element.click(); 3793 } 3794 } 3795 3796 protected void uncheckByName(String name) throws InterruptedException { 3797 uncheck(By.name(name)); 3798 } 3799 3800 protected void uncheckByXpath(String locator) throws InterruptedException { 3801 uncheck(By.xpath(locator)); 3802 } 3803 3804 protected boolean validateErrorImage(boolean validateVisible) throws Exception { 3805 Thread.sleep(500); 3806 boolean valid = false; 3807 3808 for (int second = 0; second < 5; second++) { 3809 if ((valid = validateErrorImage(validateVisible, second, ARIA_INVALID_XPATH)) == true) { 3810 break; 3811 } 3812 } 3813 3814 if (validateVisible) { 3815 SeleneseTestBase.assertTrue("valid = " + valid + " when validateVisible is " + validateVisible, valid); 3816 } else { 3817 SeleneseTestBase.assertFalse("valid = " + valid + " when validateVisible is " + validateVisible, valid); 3818 } 3819 3820 return valid; 3821 } 3822 3823 private boolean validateErrorImage(boolean validateVisible, int second, String xpath) throws InterruptedException { 3824 try { 3825 if (validateVisible) { 3826 if (isElementPresentByXpath(xpath) && isVisibleByXpath(xpath)) { 3827 return true; 3828 } 3829 } else { 3830 if (!isElementPresentByXpath(xpath) || !isVisibleByXpath(xpath)) { 3831 return true; 3832 } 3833 } 3834 } catch (Exception e) { 3835 // don't fail here, we're in a loop let the caller decide when to fail 3836 } 3837 Thread.sleep(1000); 3838 return false; 3839 } 3840 3841 protected void verifyRichMessagesValidationBasicFunctionality() throws Exception 3842 { 3843 SeleneseTestBase.assertTrue(isElementPresentByXpath("//input[@type='text' and @name='field1']")); 3844 SeleneseTestBase.assertTrue(isElementPresentByXpath("//a[contains(text(), 'Kuali')]")); 3845 SeleneseTestBase.assertTrue(isElementPresentByXpath("//input[@type='checkbox' and @name='field2']")); 3846 Thread.sleep(3000); 3847 } 3848 3849 protected void verifyRichMessagesValidationAdvancedFunctionality() throws Exception 3850 { 3851 //Color Options 3852 SeleneseTestBase.assertTrue(isElementPresentByXpath("//span[@style='color: green;']")); 3853 SeleneseTestBase.assertTrue(isElementPresentByXpath("//span[@style='color: blue;']")); 3854 3855 //Css class 3856 SeleneseTestBase.assertTrue(isElementPresentByXpath("//span[@class='fl-text-underline fl-text-larger']")); 3857 3858 //Combinations 3859 SeleneseTestBase.assertTrue(isElementPresentByXpath("//input[@type='text' and @name='field3']")); 3860 SeleneseTestBase.assertTrue(isElementPresentByXpath("//select[@name='field4']")); 3861 SeleneseTestBase.assertTrue(isElementPresentByXpath("//button[contains(text(), 'Action Button')]")); 3862 3863 //Rich Message Field 3864 SeleneseTestBase.assertTrue(isElementPresentByXpath("//label[contains(., 'Label With')]/span[contains(., 'Color')]")); 3865 SeleneseTestBase.assertTrue(isElementPresentByXpath("//label[contains(., 'Label With')]/i/b[contains(., 'Html')]")); 3866 SeleneseTestBase.assertTrue(isElementPresentByXpath("//label[contains(., 'Label With')]/img[@class='uif-image inlineBlock']")); 3867 Thread.sleep(3000); 3868 } 3869 3870 protected void verifyRichMessagesValidationLettersNumbersValidation() throws Exception 3871 { 3872 //For letters only Validation 3873 SeleneseTestBase.assertTrue(isElementPresentByXpath("//input[@type='text' and @name='field5']")); 3874 waitAndTypeByXpath( 3875 "//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock']/input[@name= 'field5']", 3876 "abc"); 3877 SeleneseTestBase.assertFalse(isElementPresentByXpath("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']")); 3878 clearTextByXpath( 3879 "//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock']/input[@name= 'field5']"); 3880 waitAndTypeByXpath("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock']/input[@name= 'field5']","abc12"); 3881 waitAndTypeByXpath("//input[@name= 'field6']", ""); 3882 SeleneseTestBase.assertTrue(isElementPresentByXpath("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']")); 3883 Thread.sleep(3000); 3884 clearTextByXpath("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']/input[@name= 'field5']"); 3885 waitAndTypeByXpath("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']/input[@name= 'field5']","abc"); 3886 waitAndTypeByXpath("//input[@name= 'field6']", ""); 3887 3888 //For numbers only validation 3889 waitAndTypeByXpath("//input[@name= 'field6']", "123"); 3890 SeleneseTestBase.assertFalse(isElementPresentByXpath("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']")); 3891 clearTextByXpath("//input[@name= 'field6']"); 3892 waitAndTypeByXpath("//input[@name= 'field6']", "123ab"); 3893 fireEvent("field6", "blur"); 3894 Thread.sleep(5000); 3895 SeleneseTestBase.assertTrue(isElementPresentByXpath("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']")); 3896 Thread.sleep(3000); 3897 } 3898 3899 protected void verifyRichMessagesValidationRadioAndCheckBoxGroupFunctionality() throws Exception 3900 { 3901 //Radio Group 3902 SeleneseTestBase.assertTrue(isElementPresentByXpath("//fieldset[@class='uif-verticalRadioFieldset']/span/input[@type='radio' and @name='field24' and @value='1']")); 3903 SeleneseTestBase.assertTrue(isElementPresentByXpath( 3904 "//fieldset[@class='uif-verticalRadioFieldset']/span/input[@type='radio' and @name='field24' and @value='2']")); 3905 SeleneseTestBase.assertTrue(isElementPresentByXpath( 3906 "//fieldset[@class='uif-verticalRadioFieldset']/span/input[@type='radio' and @name='field24' and @value='3']")); 3907 SeleneseTestBase.assertTrue(isElementPresentByXpath( 3908 "//fieldset[@class='uif-verticalRadioFieldset']/span/input[@type='radio' and @name='field24' and @value='4']")); 3909 3910 //Checkbox Group 3911 SeleneseTestBase.assertTrue(isElementPresentByXpath( 3912 "//fieldset[@class='uif-verticalCheckboxesFieldset']/span/input[@type='checkbox' and @name='field115' and @value='1']")); 3913 SeleneseTestBase.assertTrue(isElementPresentByXpath("//fieldset[@class='uif-verticalCheckboxesFieldset']/span/input[@type='checkbox' and @name='field115' and @value='2']")); 3914 SeleneseTestBase.assertTrue(isElementPresentByXpath( 3915 "//fieldset[@class='uif-verticalCheckboxesFieldset']/span/input[@type='checkbox' and @name='field115' and @value='3']")); 3916 SeleneseTestBase.assertTrue(isElementPresentByXpath( 3917 "//fieldset[@class='uif-verticalCheckboxesFieldset']/span/label/div/select[@name='field4']")); 3918 3919 //Checkbox Control 3920 SeleneseTestBase.assertTrue(isElementPresentByXpath("//input[@type='checkbox' and @name='bField1']")); 3921 SeleneseTestBase.assertTrue(isElementPresentByXpath("//input[@type='text' and @name='field103']")); 3922 } 3923 3924 protected void verifyRichMessagesValidationLinkDeclarationsFunctionality() throws Exception 3925 { 3926 //Testing link tag 3927 waitAndClickByXpath("//div[contains(., 'Testing link tag')]/a"); 3928 Thread.sleep(9000); 3929 switchToWindow("Open Source Software | www.kuali.org"); 3930 switchToWindow(RICH_MESSAGES_WINDOW_TITLE); 3931 3932 //Testing methodToCall Action 3933 waitAndClickByXpath("//div[contains(., 'Testing methodToCall action')]/a"); 3934 Thread.sleep(3000); 3935 SeleneseTestBase.assertTrue(isElementPresentByXpath( 3936 "//div[@class='uif-validationMessages uif-groupValidationMessages uif-pageValidationMessages uif-pageValidationMessages-error']")); 3937 SeleneseTestBase.assertTrue(isElementPresentByXpath( 3938 "//div[@id='Demo-AdvancedMessagesSection']/div[@class='uif-validationMessages uif-groupValidationMessages uif-pageValidationMessages-error']")); 3939 SeleneseTestBase.assertTrue(isElementPresentByXpath("//div[@id='Demo-RadioCheckboxMessageSection']/div[@class='uif-validationMessages uif-groupValidationMessages uif-pageValidationMessages-error']")); 3940 3941 //Testing methodToCall action (no client validation check) 3942 waitAndClickByXpath("//div[contains(., 'Testing methodToCall action (no client validation check)')]/a"); 3943 SeleneseTestBase.assertTrue(isElementPresentByXpath("//div[@class='uif-validationMessages uif-groupValidationMessages uif-pageValidationMessages uif-pageValidationMessages-error']")); 3944 SeleneseTestBase.assertTrue(isElementPresentByXpath("//div[@class='uif-validationMessages uif-groupValidationMessages']")); 3945 SeleneseTestBase.assertTrue(isElementPresentByXpath("//div[@class='uif-validationMessages uif-groupValidationMessages uif-pageValidationMessages uif-pageValidationMessages-error']")); 3946 SeleneseTestBase.assertTrue(isElementPresentByXpath("//div[@id='Demo-AdvancedMessagesSection']/div[@class='uif-validationMessages uif-groupValidationMessages uif-pageValidationMessages-error']")); 3947 SeleneseTestBase.assertTrue(isElementPresentByXpath("//div[@id='Demo-RadioCheckboxMessageSection']/div[@class='uif-validationMessages uif-groupValidationMessages uif-pageValidationMessages-error']")); 3948 Thread.sleep(3000); 3949 } 3950 3951 /** 3952 * {@link #ADMINISTRATION_LINK_TEXT} 3953 * @param failable 3954 * @throws InterruptedException 3955 */ 3956 protected void waitAndClickAdministration(Failable failable) throws InterruptedException { 3957 waitAndClickByLinkText(ADMINISTRATION_LINK_TEXT, failable); 3958 } 3959 3960 protected void waitAndCancelConfirmation() throws InterruptedException { 3961 waitAndClickCancel(); 3962 waitAndClickByName("methodToCall.processAnswer.button0"); 3963 } 3964 3965 protected void waitAndClick(By by) throws InterruptedException { 3966 jiraAwareWaitAndClick(by, ""); 3967 } 3968 3969 protected void waitAndClick(By by, Failable failable) throws InterruptedException { 3970 jiraAwareWaitAndClick(by, "", failable); 3971 } 3972 3973 protected void waitAndClick(String locator, String message) throws InterruptedException { 3974 jiraAwareWaitAndClick(By.cssSelector(locator), message); 3975 } 3976 3977 protected void waitAndClickById(String id) throws InterruptedException { 3978 jiraAwareWaitAndClick(By.id(id), ""); 3979 } 3980 protected void waitAndClickById(String id, String message) throws InterruptedException { 3981 jiraAwareWaitAndClick(By.id(id), message); 3982 } 3983 3984 protected void waitAndClickButtonByText(String buttonText) throws InterruptedException { 3985 waitAndClickByXpath("//button[contains(text(), '" + buttonText + "')]"); 3986 } 3987 3988 protected void waitAndClickByLinkText(String text) throws InterruptedException { 3989 jiraAwareWaitAndClick(By.linkText(text), ""); 3990 } 3991 3992 protected void waitAndClickByLinkText(String text, String message) throws InterruptedException { 3993 jiraAwareWaitAndClick(By.linkText(text), message); 3994 } 3995 3996 protected void waitAndClickByLinkText(String text, Failable failable) throws InterruptedException { 3997 jiraAwareWaitAndClick(By.linkText(text), "", failable); 3998 } 3999 4000 protected void waitAndClickByLinkText(String text, String message, Failable failable) throws InterruptedException { 4001 jiraAwareWaitAndClick(By.linkText(text), message, failable); 4002 } 4003 4004 protected void waitAndClickByName(String name) throws InterruptedException { 4005 jiraAwareWaitAndClick(By.name(name), ""); 4006 } 4007 4008 protected void waitAndClickByXpath(String xpath) throws InterruptedException { 4009 waitAndClick(By.xpath(xpath)); 4010 } 4011 4012 protected void waitAndClickByXpath(String xpath, Failable failable) throws InterruptedException { 4013 waitAndClick(By.xpath(xpath), failable); 4014 } 4015 4016 protected void waitAndClickByName(String name, String message) throws InterruptedException { 4017 jiraAwareWaitAndClick(By.name(name), message); 4018 } 4019 4020 protected void waitAndClickByXpath(String xpath, String message) throws InterruptedException { 4021 jiraAwareWaitAndClick(By.xpath(xpath), message); 4022 } 4023 4024 /** 4025 * {@link #CANCEL_NAME} 4026 * @throws InterruptedException 4027 */ 4028 protected void waitAndClickCancel() throws InterruptedException { 4029 waitAndClickByName(CANCEL_NAME); 4030 } 4031 4032 /** 4033 * {@link #CLOSE_WINDOW_XPATH_TITLE} 4034 * @throws InterruptedException 4035 */ 4036 protected void waitAndClickCloseWindow() throws InterruptedException { 4037 waitAndClickByXpath(CLOSE_WINDOW_XPATH_TITLE); 4038 } 4039 4040 /** 4041 * {@link #COPY_LINK_TEXT} 4042 * @throws InterruptedException 4043 */ 4044 protected void waitAndClickCopy() throws InterruptedException { 4045 waitAndClickByLinkText(COPY_LINK_TEXT); 4046 } 4047 4048 /** 4049 * {}@link #DOC_SEARCH_XPATH} 4050 * @throws InterruptedException 4051 */ 4052 protected void waitAndClickDocSearch() throws InterruptedException { 4053 waitAndClickByXpath(DOC_SEARCH_XPATH); 4054 } 4055 4056 /** 4057 * {@link #DOC_SEARCH_XPATH_TITLE} 4058 * @throws InterruptedException 4059 */ 4060 protected void waitAndClickDocSearchTitle() throws InterruptedException { 4061 waitAndClickByXpath(DOC_SEARCH_XPATH_TITLE); 4062 } 4063 4064 /** 4065 * {@link #LOGOUT_XPATH} 4066 * @throws InterruptedException 4067 */ 4068 protected void waitAndClickLogout() throws InterruptedException { 4069 waitAndClickLogout(this); 4070 } 4071 4072 /** 4073 * {@link #LOGOUT_XPATH} 4074 * @param failable 4075 * @throws InterruptedException 4076 */ 4077 protected void waitAndClickLogout(Failable failable) throws InterruptedException { 4078 selectTopFrame(); 4079 waitAndClickByXpath(LOGOUT_XPATH, failable); 4080 } 4081 4082 /** 4083 * {}@link #MAIN_MENU_LINK_TEXT} 4084 * @param failable 4085 * @throws InterruptedException 4086 */ 4087 protected void waitAndClickMainMenu(Failable failable) throws InterruptedException { 4088 waitAndClickByLinkText(MAIN_MENU_LINK_TEXT, failable); 4089 } 4090 4091 /** 4092 * {@link #SAVE_XPATH} 4093 * @throws InterruptedException 4094 */ 4095 protected void waitAndClickSave() throws InterruptedException { 4096 waitAndClickByXpath(SAVE_XPATH); 4097 } 4098 4099 /** 4100 * {@link #SEARCH_XPATH} 4101 * @throws InterruptedException 4102 */ 4103 private void waitAndClickSearch() throws InterruptedException { 4104 waitAndClickByXpath(SEARCH_XPATH); 4105 } 4106 4107 /** 4108 * {@link #SUBMIT_XPATH} 4109 * @throws InterruptedException 4110 */ 4111 protected void waitAndClickSubmit() throws InterruptedException { 4112 waitAndClickByXpath(SUBMIT_XPATH); 4113 } 4114 4115 4116 /** 4117 * {@link #XML_INGESTER_LINK_TEXT} 4118 * @param failable 4119 * @throws InterruptedException 4120 */ 4121 protected void waitAndClickXMLIngester(Failable failable) throws InterruptedException { 4122 waitAndClickByLinkText(XML_INGESTER_LINK_TEXT, failable); 4123 } 4124 4125 protected void waitAndType(By by, String text) throws InterruptedException { 4126 waitAndType(by, text, ""); 4127 } 4128 4129 protected void waitAndType(By by, String text, String message) throws InterruptedException { 4130 try { 4131 jiraAwareWaitFor(by, ""); 4132 WebElement element = driver.findElement(by); 4133 WebDriverUtil.highlightElement(driver, driver.findElement(by)); 4134 (driver.findElement(by)).sendKeys(text); 4135 } catch (Exception e) { 4136 JiraAwareFailureUtil.failOnMatchedJira(by.toString(), this); 4137 failableFail(e.getMessage() + " " + by.toString() + " unable to type text '" + text + "' " + message 4138 + " current url " + driver.getCurrentUrl() 4139 + "\n" + ITUtil.deLinespace(driver.getPageSource())); 4140 } 4141 } 4142 4143 protected void waitAndType(String selector, String text) throws InterruptedException { 4144 waitAndType(By.cssSelector(selector), text); 4145 } 4146 4147 protected void waitAndTypeById(String id, String text) throws InterruptedException { 4148 waitAndType(By.id(id), text); 4149 } 4150 4151 protected void waitAndTypeByXpath(String locator, String text) throws InterruptedException { 4152 waitAndType(By.xpath(locator), text); 4153 } 4154 4155 protected void waitAndTypeByXpath(String locator, String text, String message) throws InterruptedException { 4156 waitAndType(By.xpath(locator), text, message); 4157 } 4158 4159 protected void waitAndTypeByName(String name, String text) throws InterruptedException { 4160 waitAndType(By.name(name), text); 4161 } 4162 4163 protected void waitAndCreateNew() throws InterruptedException { 4164 selectFrameIframePortlet(); 4165 try { 4166 jGrowl("Create New"); 4167 waitAndClickCreateNew(); // timing out in CI rice-trunk-smoke-test-jdk7/494 4168 } catch (Exception e) { 4169 System.out.println("waitAndClickByXpath(\"//img[@alt='create new']\") failed trying title method with " + e.getMessage()); 4170 waitAndClickByXpath("//a[@title='Create a new record']"); 4171 } 4172 } 4173 4174 /** 4175 * {@link #CREATE_NEW_XPATH} 4176 * @throws InterruptedException 4177 */ 4178 protected void waitAndClickCreateNew() throws InterruptedException { 4179 waitAndClickByXpath(CREATE_NEW_XPATH); 4180 } 4181 4182 protected void waitAndClickEdit() throws InterruptedException { 4183 waitAndClickByLinkText(EDIT_LINK_TEXT); 4184 } 4185 4186 protected void waitAndClickReturnValue() throws InterruptedException { 4187 waitAndClickByLinkText(RETURN_VALUE_LINK_TEXT); 4188 } 4189 4190 protected void waitAndClickSearch2() throws InterruptedException { 4191 waitAndClickByXpath(SEARCH_XPATH_2); 4192 } 4193 4194 protected void waitAndClickSearch3() throws InterruptedException { 4195 waitAndClickByXpath(SEARCH_XPATH_3); 4196 } 4197 4198 protected String waitForDocId() throws InterruptedException { 4199 checkForDocError(); 4200 waitForElementPresentByXpath(DOC_ID_XPATH); 4201 4202 return driver.findElement(By.xpath(DOC_ID_XPATH)).getText(); 4203 } 4204 4205 protected void waitForElementPresent(By by) throws InterruptedException { 4206 jiraAwareWaitFor(by, ""); 4207 } 4208 4209 protected void waitForElementPresent(String locator) throws InterruptedException { 4210 jiraAwareWaitFor(By.cssSelector(locator), ""); 4211 } 4212 4213 protected void waitForElementPresentByClassName(String name) throws InterruptedException { 4214 jiraAwareWaitFor(By.className(name), ""); 4215 } 4216 4217 protected void waitForElementPresentByClassName(String name, String message) throws InterruptedException { 4218 jiraAwareWaitFor(By.className(name), message); 4219 } 4220 4221 protected void waitForElementsPresentByClassName(String name, String message) throws InterruptedException { 4222 jiraAwareWaitFors(By.className(name), message); 4223 } 4224 4225 protected void waitForElementPresentById(String id) throws InterruptedException { 4226 jiraAwareWaitFor(By.id(id), ""); 4227 } 4228 4229 protected void waitForElementPresentByName(String name) throws InterruptedException { 4230 jiraAwareWaitFor(By.name(name), ""); 4231 } 4232 4233 protected void waitForElementPresentByXpath(String locator) throws InterruptedException { 4234 jiraAwareWaitFor(By.xpath(locator), ""); 4235 } 4236 4237 protected void waitForElementsPresentByXpath(String xpathLocator) throws InterruptedException { 4238 jiraAwareWaitFors(By.xpath(xpathLocator), ""); 4239 } 4240 4241 protected void waitForTitleToEqualKualiPortalIndex() throws InterruptedException { 4242 waitForTitleToEqualKualiPortalIndex(""); 4243 } 4244 4245 protected void waitIsVisible(By by) throws InterruptedException { 4246 driver.manage().timeouts().implicitlyWait(waitSeconds, TimeUnit.SECONDS); 4247 isVisible(by); 4248 driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS); 4249 4250 // for (int second = 0;; second++) { 4251 // if (second >= waitSeconds) { 4252 // failableFail(TIMEOUT_MESSAGE + " " + by.toString()); 4253 // } 4254 // if (isVisible(by)) { 4255 // break; 4256 // } 4257 // Thread.sleep(1000); 4258 // } 4259 } 4260 4261 protected void waitIsVisible(By by, String message) throws InterruptedException { 4262 for (int second = 0;; second++) { 4263 if (second >= waitSeconds) { 4264 failableFail(TIMEOUT_MESSAGE + " " + by.toString() + " " + message); 4265 } 4266 if (isVisible(by)) { 4267 break; 4268 } 4269 Thread.sleep(1000); 4270 } 4271 } 4272 4273 protected boolean waitAreAnyVisible(By[] bys) throws InterruptedException { 4274 if (bys == null || bys.length == 0 ) { 4275 return false; 4276 } 4277 4278 for (int second = 0; second < waitSeconds; second++) { 4279 4280 if (isVisible(bys)) { 4281 return true; 4282 } 4283 4284 Thread.sleep(1000); 4285 } 4286 4287 return false; 4288 } 4289 4290 protected boolean isVisible(By[] bys) { 4291 if (bys == null || bys.length == 0 ) { 4292 return false; 4293 } 4294 4295 for (int i = 0, s = bys.length; i < s; i++) { 4296 4297 try { 4298 4299 if (isVisible(bys[i])) { 4300 return true; 4301 } 4302 4303 } catch (NoSuchElementException nsee) { 4304 // don't fail 4305 } 4306 4307 } 4308 4309 return false; 4310 } 4311 4312 /** 4313 * Uses Selenium's findElements method which does not throw a test exception if not found. 4314 * @param elementLocator 4315 * @param message 4316 * @throws InterruptedException 4317 */ 4318 protected void waitForElementVisible(String elementLocator, String message) throws InterruptedException { 4319 boolean failed = false; 4320 4321 for (int second = 0;; second++) { 4322 if (second >= waitSeconds) 4323 failed = true; 4324 try { 4325 if (failed || (driver.findElements(By.cssSelector(elementLocator))).size() > 0) 4326 break; 4327 } catch (Exception e) {} 4328 Thread.sleep(1000); 4329 } 4330 4331 checkForIncidentReport(elementLocator); // after timeout to be sure page is loaded 4332 4333 if (failed) 4334 failableFail("timeout of " + waitSeconds + " seconds waiting for " + elementLocator + " " + message + " " + driver.getCurrentUrl()); 4335 } 4336 4337 protected void waitIsVisible(String locator) throws InterruptedException { 4338 waitIsVisible(By.cssSelector(locator)); 4339 } 4340 4341 protected void waitIsVisibleByXpath(String locator) throws InterruptedException { 4342 waitIsVisible(By.xpath(locator)); 4343 } 4344 4345 protected void waitIsVisibleByXpath(String locator, String message) throws InterruptedException { 4346 waitIsVisible(By.xpath(locator), message); 4347 } 4348 4349 protected void waitForTitleToEqualKualiPortalIndex(String message) throws InterruptedException { 4350 Thread.sleep(2000); 4351 // This started failing in CI.... 4352 // boolean failed = false; 4353 // 4354 // for (int second = 0;; second++) { 4355 // Thread.sleep(1000); 4356 // if (second >= waitSeconds) failed = true; 4357 // try { if (failed || ITUtil.KUALI_PORTAL_TITLE.equals(driver.getTitle())) break; } catch (Exception e) {} 4358 // } 4359 4360 // WebDriverUtil.checkForIncidentReport(driver, message); // after timeout to be sure page is loaded 4361 // if (failed) failableFail("timeout of " + waitSeconds + " seconds " + message); 4362 } 4363 4364 protected void waitAndClick(String locator) throws InterruptedException { 4365 waitAndClick(locator, ""); 4366 } 4367 4368 protected void waitForPageToLoad() { 4369 // noop webdriver doesn't it need it, except when it does... 4370 } 4371 4372 protected void waitFor(By by) throws InterruptedException { 4373 jiraAwareWaitFor(by, ""); 4374 } 4375 4376 /** 4377 * Should be called from jiraAwareWaitFor to get KULRICE error output in CI. 4378 * 4379 * Inner most waitFor, let it throw the failure so the timeout message reflects the waitSeconds time, not the 1 4380 * second it is set to before returning. 4381 * @param by 4382 * @param message 4383 * @throws InterruptedException 4384 */ 4385 protected void waitFor(By by, String message) throws InterruptedException { 4386 WebDriverUtil.waitFor(this.driver, this.waitSeconds, by, message); 4387 } 4388 4389 /** 4390 * {@link #KRAD_XPATH} 4391 * @throws InterruptedException 4392 */ 4393 protected void waitAndClickKRAD() throws InterruptedException { 4394 waitAndClickByLinkText(KRAD_XPATH); 4395 } 4396 4397 protected void waitNotVisible(By by) throws InterruptedException { 4398 for (int second = 0;; second++) { 4399 if (second >= waitSeconds) { 4400 failableFail(TIMEOUT_MESSAGE); 4401 } 4402 if (!isVisible(by)) { 4403 break; 4404 } 4405 Thread.sleep(1000); 4406 } 4407 } 4408 4409 protected void waitNotVisibleByXpath(String locator) throws InterruptedException { 4410 waitNotVisible(By.xpath(locator)); 4411 } 4412 4413 /** 4414 * Does the test page use KRAD UIF? 4415 * Useful if trying to re-use a test for both a KNS and KRAD screens that have different paths to the elements. 4416 * @return 4417 */ 4418 protected boolean isKrad(){ 4419 return (ITUtil.REMOTE_UIF_KRAD.equalsIgnoreCase(getUiFramework())); 4420 } 4421 4422 protected WebElement getElementByDataAttributeValue(String dataAttributeName, String value){ 4423 return driver.findElement(By.cssSelector("[data-" + dataAttributeName + "='" + value +"']")); 4424 } 4425 4426 protected WebElement getElementByDataAttribute(String dataAttributeName){ 4427 return driver.findElement(By.cssSelector("[data-" + dataAttributeName + "]")); 4428 } 4429 4430 protected WebElement getElementByAttributeValue(String attributeName, String value){ 4431 return driver.findElement(By.cssSelector("[" + attributeName + "='" + value +"']")); 4432 } 4433 4434 protected WebElement getElementByAttribute(String attributeName){ 4435 return driver.findElement(By.cssSelector("[" + attributeName + "]")); 4436 } 4437 4438 /** 4439 * Returns the label text of a label-for element 4440 * <p> 4441 * For usage with elements like this: <label for="some-element-id">The text of the Label</label> 4442 * </p> 4443 * 4444 * @param forElementId the id of the element for which to find the label text 4445 * @return label text 4446 */ 4447 protected String getForLabelText(String forElementId) { 4448 return driver.findElement(By.cssSelector("label[for=" + forElementId + "]")).getText(); 4449 } 4450 4451 /** 4452 * Determines whether KRAD or KNS UIF is used for this test. 4453 * Useful if trying to re-use a test for both a KNS and KRAD screens that have different paths to the elements. 4454 * @return 4455 */ 4456 public String getUiFramework() { 4457 return uiFramework; 4458 } 4459 4460 /** 4461 * Sets which UIF is used by this test 4462 */ 4463 public void setUiFramework(String uiFramework) { 4464 this.uiFramework = uiFramework; 4465 } 4466 }