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