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