001 /** 002 * Copyright 2005-2012 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 org.apache.commons.lang.RandomStringUtils; 019 import static com.thoughtworks.selenium.SeleneseTestBase.fail; 020 import static org.junit.Assert.assertEquals; 021 022 import java.io.BufferedReader; 023 import java.io.InputStreamReader; 024 import java.net.HttpURLConnection; 025 import java.net.URL; 026 import java.util.Calendar; 027 import java.util.List; 028 import java.util.Set; 029 import java.util.concurrent.TimeUnit; 030 import org.apache.commons.lang.RandomStringUtils; 031 import org.junit.After; 032 import org.junit.Assert; 033 import org.junit.Before; 034 import org.junit.BeforeClass; 035 import org.junit.Rule; 036 import org.junit.rules.TestName; 037 import org.openqa.selenium.By; 038 import org.openqa.selenium.JavascriptExecutor; 039 import org.openqa.selenium.NoSuchFrameException; 040 import org.openqa.selenium.WebDriver; 041 import org.openqa.selenium.WebElement; 042 import org.openqa.selenium.chrome.ChromeDriverService; 043 import org.openqa.selenium.interactions.Actions; 044 import org.openqa.selenium.remote.RemoteWebDriver; 045 import org.openqa.selenium.support.ui.Select; 046 import java.io.BufferedReader; 047 import java.io.InputStreamReader; 048 import java.net.HttpURLConnection; 049 import java.net.URL; 050 import java.util.Calendar; 051 import java.util.Date; 052 import java.util.List; 053 import java.util.Set; 054 import java.util.concurrent.TimeUnit; 055 import static com.thoughtworks.selenium.SeleneseTestBase.fail; 056 import static org.junit.Assert.assertEquals; 057 import org.openqa.selenium.support.ui.Select; 058 059 /** 060 * Class to upgrade UpgradedSeleniumITBase tests to WebDriver. 061 * @deprecated Use WebDriverITBase for new tests. 062 * @author Kuali Rice Team (rice.collab@kuali.org) 063 */ 064 public abstract class WebDriverLegacyITBase { //implements com.saucelabs.common.SauceOnDemandSessionIdProvider { 065 066 public static final int DEFAULT_WAIT_SEC = 60; 067 public static final String REMOTE_PUBLIC_USERPOOL_PROPERTY = "remote.public.userpool"; 068 public static final String REMOTE_PUBLIC_USER_PROPERTY = "remote.public.user"; 069 070 public abstract String getTestUrl(); 071 072 protected WebDriver driver; 073 protected String user = "admin"; 074 protected boolean passed = false; 075 static ChromeDriverService chromeDriverService; 076 077 public @Rule 078 TestName testName = new TestName(); 079 080 String sessionId = null; 081 082 public String getSessionId() { 083 return sessionId; 084 } 085 086 @BeforeClass 087 public static void createAndStartService() throws Exception { 088 chromeDriverService = WebDriverUtil.createAndStartService(); 089 if (chromeDriverService != null) 090 chromeDriverService.start(); 091 } 092 093 /** 094 * Setup the WebDriver test, login and load the tested web page 095 * 096 * @throws Exception 097 */ 098 @Before 099 public void setUp() throws Exception { 100 // {"test":"1","user":"1"} 101 try { 102 if (System.getProperty(REMOTE_PUBLIC_USER_PROPERTY) != null) { 103 user = System.getProperty(REMOTE_PUBLIC_USER_PROPERTY); 104 } else if (System.getProperty(REMOTE_PUBLIC_USERPOOL_PROPERTY) != null) { // deprecated 105 String userResponse = getHTML(ITUtil.prettyHttp(System.getProperty(REMOTE_PUBLIC_USERPOOL_PROPERTY) 106 + "?test=" + this.toString().trim())); 107 user = userResponse.substring(userResponse.lastIndexOf(":") + 2, userResponse.lastIndexOf("\"")); 108 } 109 driver = WebDriverUtil.setUp(getUserName(), ITUtil.getBaseUrlString() + getTestUrl(), getClass() 110 .getSimpleName(), testName); 111 this.sessionId = ((RemoteWebDriver) driver).getSessionId().toString(); 112 } catch (Exception e) { 113 fail("Exception in setUp " + e.getMessage()); 114 e.printStackTrace(); 115 } 116 ITUtil.login(driver, user); 117 } 118 119 @After 120 public void tearDown() throws Exception { 121 try { 122 // if (System.getProperty(SauceLabsWebDriverHelper.SAUCE_PROPERTY) != null) { 123 // SauceLabsWebDriverHelper.tearDown(passed, sessionId, System.getProperty(SauceLabsWebDriverHelper.SAUCE_USER_PROPERTY), System.getProperty(SauceLabsWebDriverHelper.SAUCE_KEY_PROPERTY)); 124 // } 125 if (System.getProperty(REMOTE_PUBLIC_USERPOOL_PROPERTY) != null) { 126 getHTML(ITUtil.prettyHttp(System.getProperty(REMOTE_PUBLIC_USERPOOL_PROPERTY) + "?test=" 127 + this.toString() + "&user=" + user)); 128 } 129 } catch (Exception e) { 130 System.out.println("Exception in tearDown " + e.getMessage()); 131 e.printStackTrace(); 132 } finally { 133 if (driver != null) { 134 if (ITUtil.dontTearDownPropertyNotSet()) { 135 driver.close(); 136 driver.quit(); 137 } 138 } else { 139 System.out 140 .println("WebDriver is null, if using saucelabs, has sauceleabs been uncommented in WebDriverUtil.java? If using a remote hub did you include the port?"); 141 } 142 } 143 } 144 145 protected String getHTML(String urlToRead) { 146 URL url; 147 HttpURLConnection conn; 148 BufferedReader rd; 149 String line; 150 String result = ""; 151 try { 152 url = new URL(urlToRead); 153 conn = (HttpURLConnection) url.openConnection(); 154 conn.setRequestMethod("GET"); 155 rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); 156 while ((line = rd.readLine()) != null) { 157 result += line; 158 } 159 rd.close(); 160 } catch (Exception e) { 161 e.printStackTrace(); 162 } 163 return result; 164 } 165 166 protected void passed() { 167 passed = true; 168 } 169 170 protected void assertElementPresentByName(String name) { 171 driver.findElement(By.name(name)); 172 } 173 174 protected void assertElementPresentByName(String name, String message) { 175 try { 176 driver.findElement(By.name(name)); 177 } catch (Exception e) { 178 Assert.fail(name + " not present " + message); 179 } 180 } 181 182 protected void assertElementPresentByXpath(String locator) { 183 driver.findElement(By.xpath(locator)); 184 } 185 186 protected void assertElementPresentByXpath(String locator, String message) { 187 try { 188 driver.findElement(By.xpath(locator)); 189 } catch (Exception e) { 190 Assert.fail(locator + " not present " + message); 191 } 192 } 193 194 protected void assertElementPresentByLinkText(String linkText) { 195 driver.findElement(By.linkText(linkText)); 196 } 197 198 protected void assertElementPresent(String locator) { 199 driver.findElement(By.cssSelector(locator)); 200 } 201 202 protected void assertTextPresent(String text) { 203 assertTextPresent(text, ""); 204 } 205 206 protected void assertTextPresent(String text, String message) { 207 if (!driver.getPageSource().contains(text)) { 208 Assert.fail(text + " not present " + message); 209 } 210 } 211 212 protected void blanketApproveTest() throws InterruptedException { 213 ITUtil.checkForIncidentReport(driver.getPageSource(), "methodToCall.blanketApprove", ""); 214 waitAndClickByName("methodToCall.blanketApprove", "No blanket approve button does the user " + getUserName() 215 + " have permission?"); 216 Thread.sleep(2000); 217 218 if (driver.findElements(By.xpath(ITUtil.DIV_ERROR_LOCATOR)).size() > 0) { 219 String errorText = driver.findElement(By.xpath(ITUtil.DIV_ERROR_LOCATOR)).getText(); 220 if (errorText != null && errorText.contains("error(s) found on page.")) { 221 errorText = ITUtil.blanketApprovalCleanUpErrorText(errorText); 222 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) 223 errorText = ITUtil.blanketApprovalCleanUpErrorText(driver.findElement( 224 By.xpath(ITUtil.DIV_EXCOL_LOCATOR)).getText()); // replacing errorText as DIV_EXCOL_LOCATOR includes the error count 225 } 226 227 // if (selenium.isElementPresent("//div[@class='left-errmsg']/div")) { 228 // errorText = errorText + " " + selenium.getText("//div[@class='left-errmsg']/div/div[1]"); 229 // } 230 Assert.fail(errorText); 231 } 232 } 233 ITUtil.checkForIncidentReport(driver.getPageSource(), "//img[@alt='doc search']", "Blanket Approve failure"); 234 waitAndClickByXpath("//img[@alt='doc search']"); 235 assertEquals("Kuali Portal Index", driver.getTitle()); 236 selectFrame("iframeportlet"); 237 waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']"); 238 } 239 240 protected void checkForIncidentReport() { 241 checkForIncidentReport("", ""); 242 } 243 244 protected void checkForIncidentReport(String locator) { 245 checkForIncidentReport(locator, ""); 246 } 247 248 protected void checkForIncidentReport(String locator, String message) { 249 WebDriverUtil.checkForIncidentReport(driver, locator, message); 250 } 251 252 protected void clearText(By by) throws InterruptedException { 253 driver.findElement(by).clear(); 254 } 255 256 protected void clearText(String selector) throws InterruptedException { 257 clearText(By.cssSelector(selector)); 258 } 259 260 protected void clearTextByName(String name) throws InterruptedException { 261 clearText(By.name(name)); 262 } 263 264 protected void clearTextByXpath(String locator) throws InterruptedException { 265 clearText(By.xpath(locator)); 266 } 267 268 protected String getAttribute(By by, String attribute) throws InterruptedException { 269 waitFor(by); 270 return driver.findElement(by).getAttribute(attribute); 271 } 272 273 /** 274 * Get value of any attribute by using element name 275 * 276 * @param name name of an element 277 * @param attribute the name of an attribute whose value is to be retrieved 278 */ 279 protected String getAttributeByName(String name, String attribute) throws InterruptedException { 280 return getAttribute(By.name(name), attribute); 281 } 282 283 /** 284 * Get value of any attribute by using element xpath 285 * 286 * @param locator locating mechanism of an element 287 * @param attribute the name of an attribute whose value is to be retrieved 288 */ 289 protected String getAttributeByXpath(String locator, String attribute) throws InterruptedException { 290 return getAttribute(By.xpath(locator), attribute); 291 } 292 293 protected String getBaseUrlString() { 294 return ITUtil.getBaseUrlString(); 295 } 296 297 protected String getText(By by) throws InterruptedException { 298 return driver.findElement(by).getText(); 299 } 300 301 protected String getTextByName(String name) throws InterruptedException { 302 return getText(By.name(name)); 303 } 304 305 protected String getText(String locator) throws InterruptedException { 306 return getText(By.cssSelector(locator)); 307 } 308 309 protected String getTextByXpath(String locator) throws InterruptedException { 310 return getText(By.xpath(locator)); 311 } 312 313 protected String getTitle() { 314 return driver.getTitle(); 315 } 316 317 /** 318 * Override in test to define a user other than admin 319 * @return 320 */ 321 public String getUserName() { 322 return user; 323 } 324 325 /** 326 * Handles simple nested frame content; validates that a frame and nested frame exists before 327 * switching to it 328 */ 329 protected void gotoNestedFrame() { 330 driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS); 331 driver.switchTo().defaultContent(); 332 if (driver.findElements(By.xpath("//iframe")).size() > 0) { 333 WebElement containerFrame = driver.findElement(By.xpath("//iframe")); 334 driver.switchTo().frame(containerFrame); 335 } 336 if (driver.findElements(By.xpath("//iframe")).size() > 0) { 337 WebElement contentFrame = driver.findElement(By.xpath("//iframe")); 338 driver.switchTo().frame(contentFrame); 339 } 340 driver.manage().timeouts().implicitlyWait(DEFAULT_WAIT_SEC, TimeUnit.SECONDS); 341 } 342 343 protected boolean isElementPresent(By by) { 344 return (driver.findElements(by)).size() > 0; 345 } 346 347 protected boolean isElementPresent(String locator) { 348 return (driver.findElements(By.cssSelector(locator))).size() > 0; 349 } 350 351 protected boolean isElementPresentByName(String name) { 352 return isElementPresent(By.name(name)); 353 } 354 355 protected boolean isElementPresentByXpath(String locator) { 356 return isElementPresent(By.xpath(locator)); 357 } 358 359 protected boolean isElementPresentByLinkText(String locator) { 360 return isElementPresent(By.linkText(locator)); 361 } 362 363 protected void open(String url) { 364 driver.get(url); 365 } 366 367 protected void selectFrame(String locator) { 368 if ("iframeportlet".equals(locator)) { 369 gotoNestedFrame(); 370 } else { 371 try { 372 driver.switchTo().frame(locator); 373 } catch (NoSuchFrameException nsfe) { 374 // don't fail 375 } 376 } 377 } 378 379 protected void selectTopFrame() { 380 driver.switchTo().defaultContent(); 381 } 382 383 protected void selectWindow(String locator) { 384 driver.switchTo().window(locator); 385 } 386 387 protected void close() { 388 driver.close(); 389 } 390 391 protected void testCancelConfirmation() throws InterruptedException { 392 waitAndCancelConfirmation(); 393 passed(); 394 } 395 396 protected void testCreateNewSearchReturnValueCancelConfirmation() throws InterruptedException, Exception { 397 selectFrame("iframeportlet"); 398 waitAndCreateNew(); 399 waitAndSearch(); 400 waitAndReturnValue(); 401 waitAndCancelConfirmation(); 402 passed(); 403 } 404 405 protected void testSearchEditCancel() throws InterruptedException { 406 selectFrame("iframeportlet"); 407 waitAndSearch(); 408 waitAndEdit(); 409 testCancelConfirmation(); 410 } 411 412 protected void testVerifyAddDeleteFiscalOfficerLegacy() throws Exception { 413 selectFrame("iframeportlet"); 414 waitAndTypeByName("document.documentHeader.documentDescription", ITUtil.DTS_TWO); 415 waitAndTypeByName( 416 "newCollectionLines['document.newMaintainableObject.dataObject.fiscalOfficer.accounts'].number", 417 "1234567890"); 418 waitAndTypeByName( 419 "newCollectionLines['document.newMaintainableObject.dataObject.fiscalOfficer.accounts'].foId", "2"); 420 421 waitAndClickByXpath("//button[@data-loadingmessage='Adding Line...']"); 422 423 waitForElementPresentByName("document.newMaintainableObject.dataObject.fiscalOfficer.accounts[0].number"); 424 425 assertEquals( 426 "1234567890", 427 getAttributeByName("document.newMaintainableObject.dataObject.fiscalOfficer.accounts[0].number", 428 "value")); 429 assertEquals("2", 430 getAttributeByName("document.newMaintainableObject.dataObject.fiscalOfficer.accounts[0].foId", "value")); 431 432 waitAndClickByXpath("//button[@data-loadingmessage='Deleting Line...']"); 433 Thread.sleep(3000); 434 assertEquals(Boolean.FALSE, 435 isElementPresentByName("document.newMaintainableObject.dataObject.fiscalOfficer.accounts[0].number")); 436 passed(); 437 } 438 439 protected void waitAndCancelConfirmation() throws InterruptedException { 440 waitAndClickByName("methodToCall.cancel"); 441 waitAndClickByName("methodToCall.processAnswer.button0"); 442 } 443 444 protected void waitAndCreateNew() throws InterruptedException { 445 waitAndClickByXpath("//img[@alt='create new']"); 446 // waitAndClickByXpath("//a[@title='Create a new record']"); 447 } 448 449 protected void waitAndEdit() throws InterruptedException { 450 waitAndClickByLinkText("edit"); 451 } 452 453 protected void waitAndReturnValue() throws InterruptedException { 454 waitAndClickByLinkText("return value"); 455 } 456 457 protected void waitAndSearch() throws InterruptedException { 458 waitAndClickByXpath("//input[@value='search']"); 459 // waitAndClickByXpath("//input[@name='methodToCall.search']"); 460 // waitAndClick("input[alt='search']"); 461 // waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']"); 462 } 463 464 protected String waitForDocId() throws InterruptedException { 465 waitForElementPresentByXpath("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]"); 466 return driver.findElement(By.xpath("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]")).getText(); 467 } 468 469 protected void waitForElementPresent(String locator) throws InterruptedException { 470 waitFor(By.cssSelector(locator)); 471 } 472 473 protected void waitForElementPresentByXpath(String locator) throws InterruptedException { 474 waitFor(By.xpath(locator)); 475 } 476 477 protected void waitForElementPresentByName(String name) throws InterruptedException { 478 waitFor(By.name(name)); 479 } 480 481 protected void waitForTitleToEqualKualiPortalIndex() throws InterruptedException { 482 waitForTitleToEqualKualiPortalIndex(""); 483 } 484 485 protected void waitForTitleToEqualKualiPortalIndex(String message) throws InterruptedException { 486 Thread.sleep(2000); 487 // This started failing in CI.... 488 // boolean failed = false; 489 // for (int second = 0;; second++) { 490 // Thread.sleep(1000); 491 // if (second >= 60) failed = true; 492 // try { if (failed || ITUtil.KUALI_PORTAL_TITLE.equals(driver.getTitle())) break; } catch (Exception e) {} 493 // } 494 // WebDriverUtil.checkForIncidentReport(driver, message); // after timeout to be sure page is loaded 495 // if (failed) fail("timeout of " + 60 + " seconds " + message); 496 } 497 498 protected void waitAndClick(String locator) throws InterruptedException { 499 waitAndClick(locator, ""); 500 } 501 502 protected void waitForPageToLoad() { 503 // noop webdriver doesn't it need it, except when it does... 504 } 505 506 protected void waitFor(By by) throws InterruptedException { 507 waitFor(by, ""); 508 } 509 510 protected void waitFor(By by, String message) throws InterruptedException { 511 // for (int second = 0;; second++) { 512 Thread.sleep(1000); 513 driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); 514 515 // if (second >= DEFAULT_WAIT_SEC) fail(by.toString() + " " + message + " " + DEFAULT_WAIT_SEC + " sec timeout."); 516 try { 517 driver.findElement(by); 518 //break; 519 } catch (Exception e) {} 520 driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS); 521 // } 522 } 523 524 protected void waitAndClick(By by) throws InterruptedException { 525 waitAndClick(by, ""); 526 } 527 528 protected void waitAndClick(By by, String message) throws InterruptedException { 529 waitFor(by, message); 530 try { 531 (driver.findElement(by)).click(); 532 } catch (Exception e) { 533 fail(e.getMessage() + " " + by.toString() + " " + message + " " + driver.getCurrentUrl()); 534 e.printStackTrace(); 535 } 536 } 537 538 protected void waitAndClick(String locator, String message) throws InterruptedException { 539 waitAndClick(By.cssSelector(locator), message); 540 } 541 542 protected void waitAndClickByLinkText(String text) throws InterruptedException { 543 waitAndClick(By.linkText(text), ""); 544 } 545 546 protected void waitAndClickByLinkText(String text, String message) throws InterruptedException { 547 waitAndClick(By.linkText(text), message); 548 } 549 550 protected void waitAndClickByName(String name) throws InterruptedException { 551 waitAndClick(By.name(name), ""); 552 } 553 554 protected void waitAndClickByXpath(String xpath) throws InterruptedException { 555 waitAndClick(By.xpath(xpath)); 556 } 557 558 protected void waitAndClickByName(String name, String message) throws InterruptedException { 559 waitAndClick(By.name(name), message); 560 } 561 562 protected void waitAndClickByXpath(String xpath, String message) throws InterruptedException { 563 waitAndClick(By.xpath(xpath), message); 564 } 565 566 protected void waitAndType(By by, String text) throws InterruptedException { 567 waitFor(by, ""); 568 try { 569 (driver.findElement(by)).sendKeys(text); 570 } catch (Exception e) { 571 fail(e.getMessage() + " " + by.toString() + " unable to type text '" + text + "' current url " 572 + driver.getCurrentUrl() 573 + "\n" + ITUtil.deLinespace(driver.getPageSource())); 574 e.printStackTrace(); 575 } 576 } 577 578 protected void waitAndType(By by, String text, String message) throws InterruptedException { 579 waitFor(by, ""); 580 try { 581 (driver.findElement(by)).sendKeys(text); 582 } catch (Exception e) { 583 fail(e.getMessage() + " " + by.toString() + " unable to type text '" + text + "' " + message 584 + " current url " + driver.getCurrentUrl() 585 + "\n" + ITUtil.deLinespace(driver.getPageSource())); 586 e.printStackTrace(); 587 } 588 } 589 590 protected void waitAndType(String selector, String text) throws InterruptedException { 591 waitAndType(By.cssSelector(selector), text); 592 } 593 594 protected void waitAndTypeByXpath(String locator, String text) throws InterruptedException { 595 waitAndType(By.xpath(locator), text); 596 } 597 598 protected void waitAndTypeByXpath(String locator, String text, String message) throws InterruptedException { 599 waitAndType(By.xpath(locator), text, message); 600 } 601 602 protected void waitAndTypeByName(String name, String text) throws InterruptedException { 603 waitAndType(By.name(name), text); 604 } 605 606 protected void selectByXpath(String locator, String selectText) throws InterruptedException { 607 select(By.xpath(locator), selectText); 608 } 609 610 protected void selectByName(String name, String selectText) throws InterruptedException { 611 select(By.name(name), selectText); 612 } 613 614 protected void select(By by, String selectText) throws InterruptedException { 615 WebElement select1 = driver.findElement(by); 616 List<WebElement> options = select1.findElements(By.tagName("option")); 617 for (WebElement option : options) { 618 if (option.getText().equals(selectText)) { 619 option.click(); 620 break; 621 } 622 } 623 } 624 625 protected void selectOptionByName(String name, String optionValue) throws InterruptedException { 626 selectOption(By.name(name), optionValue); 627 } 628 629 protected void selectOptionByXpath(String locator, String optionValue) throws InterruptedException { 630 selectOption(By.name(locator), optionValue); 631 } 632 633 protected void selectOption(By by, String optionValue) throws InterruptedException { 634 WebElement select1 = driver.findElement(by); 635 List<WebElement> options = select1.findElements(By.tagName("option")); 636 for (WebElement option : options) { 637 if (option.getAttribute("value").equals(optionValue)) { 638 option.click(); 639 break; 640 } 641 } 642 } 643 644 protected String[] getSelectOptions(By by) throws InterruptedException { 645 WebElement select1 = driver.findElement(by); 646 List<WebElement> options = select1.findElements(By.tagName("option")); 647 String[] optionValues = new String[options.size()]; 648 int counter = 0; 649 for (WebElement option : options) { 650 optionValues[counter] = option.getAttribute("value"); 651 counter++; 652 } 653 return optionValues; 654 } 655 656 protected String[] getSelectOptionsByName(String name) throws InterruptedException { 657 return getSelectOptions(By.name(name)); 658 } 659 660 protected String[] getSelectOptionsByXpath(String locator) throws InterruptedException { 661 return getSelectOptions(By.xpath(locator)); 662 } 663 664 protected int getCssCount(String selector) { 665 return getCssCount(By.cssSelector(selector)); 666 } 667 668 protected int getCssCount(By by) { 669 return (driver.findElements(by)).size(); 670 } 671 672 protected void checkErrorMessageItem(String message) 673 { 674 final String error_locator = "//li[@class='uif-errorMessageItem']"; 675 assertElementPresentByXpath(error_locator); 676 String errorText = null; 677 try { 678 errorText = getTextByXpath(error_locator); 679 } catch (InterruptedException e) { 680 e.printStackTrace(); 681 } 682 if (errorText != null && errorText.contains("errors")) { 683 Assert.fail(errorText + message); 684 } 685 686 } 687 688 protected boolean isVisible(String locator) { 689 return driver.findElement(By.cssSelector(locator)).isDisplayed(); 690 } 691 692 protected boolean isVisible(By by) { 693 return driver.findElement(by).isDisplayed(); 694 } 695 696 protected boolean isVisibleByXpath(String locator) { 697 return isVisible(By.xpath(locator)); 698 } 699 700 protected void waitNotVisible(By by) throws InterruptedException { 701 for (int second = 0;; second++) { 702 if (second >= 60) { 703 Assert.fail("timeout"); 704 } 705 706 if (!isVisible(by)) { 707 break; 708 } 709 710 Thread.sleep(1000); 711 } 712 } 713 714 protected void waitNotVisibleByXpath(String locator) throws InterruptedException { 715 waitNotVisible(By.xpath(locator)); 716 } 717 718 protected void waitIsVisible(By by) throws InterruptedException { 719 for (int second = 0;; second++) { 720 if (second >= 60) { 721 Assert.fail("timeout"); 722 } 723 if (isVisible(by)) { 724 break; 725 } 726 Thread.sleep(1000); 727 } 728 } 729 730 protected void waitForElementVisible(String elementLocator, String message) throws InterruptedException { 731 boolean failed = false; 732 for (int second = 0;; second++) { 733 if (second >= 60) 734 failed = true; 735 try { 736 if (failed || (driver.findElements(By.cssSelector(elementLocator))).size() > 0) 737 break; 738 } catch (Exception e) {} 739 Thread.sleep(1000); 740 } 741 checkForIncidentReport(elementLocator); // after timeout to be sure page is loaded 742 if (failed) 743 fail("timeout of 60 seconds waiting for " + elementLocator + " " + message + " " + driver.getCurrentUrl()); 744 } 745 746 protected void waitIsVisible(String locator) throws InterruptedException { 747 waitIsVisible(By.cssSelector(locator)); 748 } 749 750 protected void waitIsVisibleByXpath(String locator) throws InterruptedException { 751 waitIsVisible(By.xpath(locator)); 752 } 753 754 protected void colapseExpandByXpath(String clickLocator, String visibleLocator) throws InterruptedException { 755 waitAndClickByXpath(clickLocator); 756 waitNotVisibleByXpath(visibleLocator); 757 758 waitAndClickByXpath(clickLocator); 759 waitIsVisibleByXpath(visibleLocator); 760 } 761 762 protected void expandColapseByXpath(String clickLocator, String visibleLocator) throws InterruptedException { 763 waitAndClickByXpath(clickLocator); 764 waitIsVisibleByXpath(visibleLocator); 765 766 waitAndClickByXpath(clickLocator); 767 waitNotVisibleByXpath(visibleLocator); 768 } 769 770 public void switchToWindow(String title) { 771 Set<String> windows = driver.getWindowHandles(); 772 773 for (String window : windows) { 774 driver.switchTo().window(window); 775 if (driver.getTitle().contains(title)) { 776 return; 777 } 778 } 779 } 780 781 public String[] getAllWindowTitles() { 782 return (String[]) driver.getWindowHandles().toArray(); 783 } 784 785 protected void check(By by) throws InterruptedException { 786 WebElement element = driver.findElement(by); 787 if (!element.isSelected()) { 788 element.click(); 789 } 790 } 791 792 protected void checkByName(String name) throws InterruptedException { 793 check(By.name(name)); 794 } 795 796 protected void checkByXpath(String locator) throws InterruptedException { 797 check(By.xpath(locator)); 798 } 799 800 protected void uncheck(By by) throws InterruptedException { 801 WebElement element = driver.findElement(by); 802 if (element.isSelected()) { 803 element.click(); 804 } 805 } 806 807 protected void uncheckByName(String name) throws InterruptedException { 808 uncheck(By.name(name)); 809 } 810 811 protected void uncheckByXpath(String locator) throws InterruptedException { 812 uncheck(By.xpath(locator)); 813 } 814 815 protected void fireEvent(String name, String event) { 816 ((JavascriptExecutor) driver).executeScript( 817 "var elements=document.getElementsByName(\"" + name + "\");" + 818 "for (var i = 0; i < elements.length; i++){" + 819 "elements[i]." + event + "();}" 820 ); 821 } 822 823 protected void fireEvent(String name, String value, String event) { 824 ((JavascriptExecutor) driver).executeScript( 825 "var elements=document.getElementsByName(\"" + name + "\");" + 826 "for (var i = 0; i < elements.length; i++){" + 827 "if(elements[i].value=='" + value + "')" + 828 "elements[i]." + event + "();}" 829 ); 830 } 831 832 public void fireMouseOverEventByName(String name) { 833 this.fireMouseOverEvent(By.name(name)); 834 } 835 836 public void fireMouseOverEventByXpath(String locator) { 837 this.fireMouseOverEvent(By.xpath(locator)); 838 } 839 840 public void fireMouseOverEvent(By by) { 841 Actions builder = new Actions(driver); 842 Actions hover = builder.moveToElement(driver.findElement(by)); 843 hover.perform(); 844 845 } 846 847 protected Boolean isTextPresent(String text) 848 { 849 if (driver.getPageSource().contains(text)) { 850 return Boolean.TRUE; 851 } 852 return Boolean.FALSE; 853 } 854 855 protected void testAgendaEditRuleRefreshIT() throws Exception { 856 selectFrame("iframeportlet"); 857 waitAndClickByXpath("//div[@class='uif-boxLayout uif-horizontalBoxLayout clearfix']/button[1]"); // waitAndClick("id=32"); 858 Thread.sleep(3000); 859 waitAndClickByXpath("//a[@title='edit Agenda Definition with Agenda Id=T1000']", 860 "Does user have edit permissions?"); // waitAndClick("id=194_line0"); 861 checkForIncidentReport(""); 862 Thread.sleep(3000); 863 waitAndClickByXpath("//li/a[@class='agendaNode ruleNode']"); // waitAndClick("//li[@id='473_node_0_parent_root']/a"); 864 waitAndClickByXpath("//li/a[@class='agendaNode logicNode whenTrueNode']"); 865 waitAndClickByLinkText("[-] collapse all"); 866 867 // click refresh several times 868 for (int i = 0; i < 6; i++) { 869 for (int second = 0;; second++) { 870 if (second >= 60) 871 Assert.fail("timeout"); 872 try { 873 if (isElementPresent(".kr-refresh-button")) 874 break; 875 } catch (Exception e) {} 876 Thread.sleep(1000); 877 } 878 879 waitAndClick("button.kr-refresh-button"); 880 } 881 } 882 883 protected void assertBlanketApproveButtonsPresent() { 884 assertElementPresentByName("methodToCall.route"); 885 assertElementPresentByName("methodToCall.save"); 886 assertElementPresentByName("methodToCall.blanketApprove", "Blanket Approve button not present does " + user 887 + " have permssion?"); 888 assertElementPresentByName("methodToCall.close"); 889 assertElementPresentByName("methodToCall.cancel"); 890 } 891 892 protected void assertDocFinal(String docId) throws InterruptedException { 893 waitFor(By.linkText("spreadsheet")); 894 if (isElementPresent(By.linkText(docId))) { 895 assertEquals("FINAL", getDocStatus()); 896 } else { 897 assertEquals(docId, driver.findElement(By.xpath("//table[@id='row']/tbody/tr[1]/td[1]"))); 898 assertEquals("FINAL", getDocStatus()); 899 } 900 } 901 902 private String getDocStatus() { 903 return driver.findElement(By.xpath("//table[@id='row']/tbody/tr[1]/td[4]")).getText(); 904 } 905 906 protected String configNameSpaceBlanketApprove() throws Exception { 907 String docId = waitForDocId(); 908 waitAndTypeByXpath("//input[@id='document.documentHeader.documentDescription']", "Validation Test Namespace " 909 + ITUtil.DTS_TWO); 910 assertBlanketApproveButtonsPresent(); 911 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.code']", "VTN" + ITUtil.DTS_TWO); 912 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", 913 "Validation Test NameSpace " + ITUtil.DTS_TWO); 914 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.applicationId']", "RICE"); 915 return docId; 916 } 917 918 protected void testConfigNamespaceBlanketApprove() throws Exception { 919 // open(ITUtil.getBaseUrlString() + getTestUrl()); 920 selectFrame("iframeportlet"); 921 waitAndCreateNew(); 922 String docId = configNameSpaceBlanketApprove(); 923 blanketApproveTest(); 924 assertDocFinal(docId); 925 passed(); 926 } 927 928 protected void testConfigParamaterBlanketApprove() throws Exception { 929 // open(ITUtil.getBaseUrlString() + getTestUrl()); 930 selectFrame("iframeportlet"); 931 waitAndCreateNew(); 932 String docId = waitForDocId(); 933 waitAndTypeByXpath("//input[@id='document.documentHeader.documentDescription']", "Validation Test Parameter "); 934 assertBlanketApproveButtonsPresent(); 935 assertEquals("", getTextByName("methodToCall.cancel")); 936 selectByXpath("//select[@id='document.newMaintainableObject.namespaceCode']", "KR-NS - Kuali Nervous System"); 937 938 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,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" 939 + getBaseUrlString() + "/kr/lookup.do;::::).anchor4']"; 940 waitAndClickByXpath(componentLookUp); 941 waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']"); 942 waitAndClickByLinkText("return value"); 943 944 String parameterName = "ValidationTestParameter" + ITUtil.DTS; 945 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", parameterName); 946 waitAndTypeByXpath("//textarea[@id='document.newMaintainableObject.description']", 947 "Validation Test Parameter Description" + ITUtil.DTS); 948 selectByXpath("//select[@id='document.newMaintainableObject.parameterTypeCode']", "Document Validation"); 949 waitAndClickByXpath("//input[@id='document.newMaintainableObject.evaluationOperatorCodeAllowed']"); 950 951 waitForPageToLoad(); 952 blanketApproveTest(); 953 assertDocFinal(docId); 954 } 955 956 protected void testCreateNewCancel() throws Exception 957 { 958 selectFrame("iframeportlet"); 959 waitAndCreateNew(); 960 testCancelConfirmation(); 961 } 962 963 protected void testCreateDocType() throws Exception { 964 selectFrame("iframeportlet"); 965 waitAndCreateNew(); 966 assertElementPresentByXpath("//*[@name='methodToCall.route' and @alt='submit']", 967 "save button does not exist on the page"); 968 waitForElementPresentByXpath("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]"); 969 String docId = driver.findElement(By.xpath("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]")).getText(); 970 waitAndTypeByXpath("//input[@id='document.documentHeader.documentDescription']", "Creating new Document Type"); 971 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,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" 972 + getBaseUrlString() + "/kr/lookup.do;::::).anchor4']"; 973 waitAndClickByXpath(parentDocType); 974 waitForPageToLoad(); 975 Thread.sleep(2000); 976 waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']"); 977 waitForPageToLoad(); 978 waitAndClickByLinkText("return value"); 979 String docTypeName = "TestDocType" + ITUtil.DTS; 980 waitForElementPresentByXpath("//input[@id='document.newMaintainableObject.name']"); 981 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", docTypeName); 982 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.unresolvedDocHandlerUrl']", 983 "${kr.url}/maintenance.do?methodToCall=docHandler"); 984 //waitAndTypeByXpath("//input[@id='document.newMaintainableObject.actualNotificationFromAddress']", "NFA"); 985 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.label']", "TestDocument Label"); 986 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.unresolvedHelpDefinitionUrl']", 987 "default.htm?turl=WordDocuments%2Fdocumenttype.htm"); 988 989 waitAndClickByXpath("//*[@name='methodToCall.route' and @alt='submit']"); 990 checkForIncidentReport(); 991 waitForPageToLoad(); 992 driver.switchTo().defaultContent(); 993 994 waitAndClickByXpath("//a[@title='Document Search']"); 995 waitForPageToLoad(); 996 selectFrame("iframeportlet"); 997 waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']"); 998 Thread.sleep(2000); 999 1000 assertEquals(docId, driver.findElement(By.xpath("//table[@id='row']/tbody/tr[1]/td[1]")).getText()); 1001 1002 } 1003 1004 protected void testIdentityGroupBlanketApprove() throws Exception 1005 { 1006 selectFrame("iframeportlet"); 1007 waitAndCreateNew(); 1008 1009 String docId = waitForDocId(); 1010 waitAndTypeByXpath("//input[@id='document.documentHeader.documentDescription']", "Validation Test Group " 1011 + ITUtil.DTS_TWO); 1012 assertBlanketApproveButtonsPresent(); 1013 selectByXpath("//select[@id='document.groupNamespace']", AdminMenuLegacyITBase.LABEL_KUALI_KUALI_SYSTEMS); 1014 waitAndTypeByXpath("//input[@id='document.groupName']", "Validation Test Group1 " + ITUtil.DTS_TWO); 1015 waitAndClickByName("methodToCall.performLookup.(!!org.kuali.rice.kim.impl.identity.PersonImpl!!).(((principalId:member.memberId,principalName:member.memberName))).((``)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;;::::).anchorAssignees"); 1016 waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']"); 1017 waitAndClickByLinkText("return value"); 1018 waitAndClickByName("methodToCall.addMember.anchorAssignees"); 1019 waitForPageToLoad(); 1020 1021 blanketApproveTest(); 1022 assertDocFinal(docId); 1023 } 1024 1025 protected void testIdentityPermissionBlanketApprove() throws Exception { 1026 // open(ITUtil.getBaseUrlString() + getTestUrl()); 1027 selectFrame("iframeportlet"); 1028 waitAndCreateNew(); 1029 String docId = waitForDocId(); 1030 waitAndTypeByXpath("//input[@name='document.documentHeader.documentDescription']", 1031 "Validation Test Permission " + ITUtil.DTS_TWO); 1032 assertBlanketApproveButtonsPresent(); 1033 waitAndTypeByXpath("//input[@name='document.documentHeader.organizationDocumentNumber']", "10012"); 1034 selectByXpath("//select[@name='document.newMaintainableObject.namespaceCode']", 1035 AdminMenuLegacyITBase.LABEL_KUALI_KUALI_SYSTEMS); 1036 selectByXpath("//select[@name='document.newMaintainableObject.templateId']", 1037 AdminMenuLegacyITBase.LABEL_KUALI_DEFAULT); 1038 waitAndTypeByXpath("//input[@name='document.newMaintainableObject.name']", "ValidationTestPermission" 1039 + ITUtil.DTS_TWO); 1040 blanketApproveTest(); 1041 assertDocFinal(docId); 1042 } 1043 1044 protected void testIdentityPersonBlanketApprove() throws Exception { 1045 // open(ITUtil.getBaseUrlString() + getTestUrl()); 1046 selectFrame("iframeportlet"); 1047 waitAndCreateNew(); 1048 String docId = waitForDocId(); 1049 waitAndTypeByXpath("//input[@id='document.documentHeader.documentDescription']", "Validation Test Person"); 1050 assertBlanketApproveButtonsPresent(); 1051 waitAndTypeByXpath("//input[@id='document.principalName']", "principal" 1052 + RandomStringUtils.randomAlphabetic(3).toLowerCase()); 1053 selectByName("newAffln.affiliationTypeCode", "Affiliate"); 1054 selectByName("newAffln.campusCode", "BX - BLGTN OFF CAMPUS"); 1055 selectByName("newAffln.campusCode", "BL - BLOOMINGTON"); 1056 assertElementPresentByName("newAffln.dflt"); 1057 waitAndClickByName("newAffln.dflt"); 1058 waitAndClickByName("methodToCall.addAffln.anchor"); 1059 waitAndClickByName("methodToCall.toggleTab.tabContact"); 1060 selectByName("newName.namePrefix", "Mr"); 1061 waitAndTypeByName("newName.firstName", "First"); 1062 waitAndTypeByName("newName.lastName", "Last"); 1063 selectByName("newName.nameSuffix", "Mr"); 1064 waitAndClickByName("newName.dflt"); 1065 waitAndClickByName("methodToCall.addName.anchor"); 1066 waitForPageToLoad(); 1067 blanketApproveTest(); 1068 assertDocFinal(docId); 1069 } 1070 1071 protected void testIdentityResponsibilityBlanketApprove() throws Exception { 1072 // open(ITUtil.getBaseUrlString() + getTestUrl()); 1073 selectFrame("iframeportlet"); 1074 waitAndCreateNew(); 1075 String docId = waitForDocId(); 1076 waitAndTypeByXpath("//input[@id='document.documentHeader.documentDescription']", 1077 "Validation Test Responsibility " + ITUtil.DTS_TWO); 1078 assertBlanketApproveButtonsPresent(); 1079 selectByXpath("//select[@id='document.newMaintainableObject.namespaceCode']", 1080 AdminMenuLegacyITBase.LABEL_KUALI_KUALI_SYSTEMS); 1081 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", "Validation Test Responsibility " 1082 + ITUtil.DTS_TWO); 1083 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.documentTypeName']", "Test " + ITUtil.DTS_TWO); 1084 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.routeNodeName']", "Test " + ITUtil.DTS_TWO); 1085 waitAndClickByXpath("//input[@id='document.newMaintainableObject.actionDetailsAtRoleMemberLevel']"); 1086 waitAndClickByXpath("//input[@id='document.newMaintainableObject.required']"); 1087 blanketApproveTest(); 1088 assertDocFinal(docId); 1089 } 1090 1091 protected void testIdentityRoleBlanketApprove() throws Exception { 1092 // open(ITUtil.getBaseUrlString() + getTestUrl()); 1093 selectFrame("iframeportlet"); 1094 waitAndCreateNew(); 1095 waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']", "No search button to click."); 1096 waitAndClickByLinkText("return value", "No return value link"); 1097 1098 String docId = waitForDocId(); 1099 waitAndTypeByXpath("//input[@id='document.documentHeader.documentDescription']", "Validation Test Role " 1100 + ITUtil.DTS_TWO); 1101 assertBlanketApproveButtonsPresent(); 1102 selectByXpath("//select[@id='document.roleNamespace']", AdminMenuLegacyITBase.LABEL_KUALI_KUALI_SYSTEMS); 1103 waitAndTypeByXpath("//input[@id='document.roleName']", "Validation Test Role " + ITUtil.DTS_TWO, 1104 "No Role Name input to type in."); 1105 waitAndClickByName("methodToCall.performLookup.(!!org.kuali.rice.kim.impl.identity.PersonImpl!!).(((principalId:member.memberId,principalName:member.memberName))).((``)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;;::::).anchorAssignees"); 1106 waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']", "No search button to click."); 1107 waitAndClickByLinkText("return value", "No return value link"); 1108 waitAndClickByName("methodToCall.addMember.anchorAssignees"); 1109 waitForPageToLoad(); 1110 blanketApproveTest(); 1111 assertDocFinal(docId); 1112 1113 } 1114 1115 protected void testLocationCampusBlanketApprove() throws Exception { 1116 // open(ITUtil.getBaseUrlString() + getTestUrl()); 1117 selectFrame("iframeportlet"); 1118 waitAndCreateNew(); 1119 String docId = waitForDocId(); 1120 waitAndTypeByName("document.documentHeader.documentDescription", "Validation Test Campus"); 1121 assertBlanketApproveButtonsPresent(); 1122 waitAndTypeByName("document.newMaintainableObject.code", RandomStringUtils.randomAlphabetic(2)); 1123 waitAndTypeByName("document.newMaintainableObject.name", "Validation Test Campus" + ITUtil.DTS); 1124 waitAndTypeByName("document.newMaintainableObject.shortName", "VTC"); 1125 selectByName("document.newMaintainableObject.campusTypeCode", "B - BOTH"); 1126 blanketApproveTest(); 1127 assertDocFinal(docId); 1128 } 1129 1130 protected void testLocationCountryBlanketApprove() throws InterruptedException { 1131 // open(ITUtil.getBaseUrlString() + getTestUrl()); 1132 selectFrame("iframeportlet"); 1133 waitAndCreateNew(); 1134 String docId = waitForDocId(); 1135 assertBlanketApproveButtonsPresent(); 1136 String twoUpperCaseLetters = RandomStringUtils.randomAlphabetic(2).toUpperCase(); 1137 String countryName = "Validation Test Country " + ITUtil.DTS + " " + twoUpperCaseLetters; 1138 waitAndTypeByXpath("//input[@id='document.documentHeader.documentDescription']", countryName); 1139 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.code']", twoUpperCaseLetters); 1140 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", countryName); 1141 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.alternateCode']", "V" + twoUpperCaseLetters); 1142 blanketApproveTest(); 1143 assertDocFinal(docId); 1144 } 1145 1146 protected void testLocationCountyBlanketApprove() throws Exception { 1147 // open(ITUtil.getBaseUrlString() + getTestUrl()); 1148 selectFrame("iframeportlet"); 1149 waitAndCreateNew(); 1150 String docId = waitForDocId(); 1151 waitAndTypeByXpath("//input[@id='document.documentHeader.documentDescription']", "Validation Test County"); 1152 assertBlanketApproveButtonsPresent(); 1153 String countryLookUp = "//input[@name='methodToCall.performLookup.(!!org.kuali.rice.location.impl.country.CountryBo!!).(((code:document.newMaintainableObject.countryCode,))).((`document.newMaintainableObject.countryCode:code,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" 1154 + getBaseUrlString() + "/kr/lookup.do;::::).anchor4']"; 1155 waitAndClickByXpath(countryLookUp); 1156 waitAndTypeByName("code", "US"); 1157 waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']"); 1158 waitAndClickByLinkText("return value"); 1159 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.code']", RandomStringUtils.randomAlphabetic(2) 1160 .toUpperCase()); 1161 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,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" 1162 + getBaseUrlString() + "/kr/lookup.do;::::).anchor4']"; 1163 waitAndClickByXpath(stateLookUp); 1164 waitAndTypeByName("code", "IN"); 1165 waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']"); 1166 waitAndClickByLinkText("return value"); 1167 String countyName = "Validation Test County" + ITUtil.DTS; 1168 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", countyName); 1169 waitAndClickByXpath("//input[@id='document.newMaintainableObject.active']"); 1170 blanketApproveTest(); 1171 assertDocFinal(docId); 1172 } 1173 1174 protected void testLocationPostBlanketApprove() throws Exception { 1175 // open(ITUtil.getBaseUrlString()+getTestUrl()); 1176 selectFrame("iframeportlet"); 1177 waitAndCreateNew(); 1178 String docId = waitForDocId(); 1179 waitAndTypeByXpath("//input[@id='document.documentHeader.documentDescription']", "Validation Test Postal Code"); 1180 assertBlanketApproveButtonsPresent(); 1181 String countryLookUp = "//input[@name='methodToCall.performLookup.(!!org.kuali.rice.location.impl.country.CountryBo!!).(((code:document.newMaintainableObject.countryCode,))).((`document.newMaintainableObject.countryCode:code,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" 1182 + getBaseUrlString() + "/kr/lookup.do;::::).anchor4']"; 1183 waitAndClickByXpath(countryLookUp); 1184 waitAndTypeByName("code", "US"); 1185 waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']"); 1186 waitAndClickByLinkText("return value"); 1187 String code = RandomStringUtils.randomNumeric(5); 1188 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.code']", code); 1189 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,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" 1190 + getBaseUrlString() + "/kr/lookup.do;::::).anchor4']"; 1191 waitAndClickByXpath(stateLookUp); 1192 waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']"); 1193 waitAndClickByXpath("//table[@id='row']/tbody/tr[4]/td[1]/a"); 1194 String cityName = "Validation Test Postal Code " + code; 1195 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.cityName']", cityName); 1196 blanketApproveTest(); 1197 assertDocFinal(docId); 1198 } 1199 1200 protected void testLocationStateBlanketApprove() throws Exception { 1201 // open(ITUtil.getBaseUrlString() + getTestUrl()); 1202 selectFrame("iframeportlet"); 1203 waitAndCreateNew(); 1204 String docId = waitForDocId(); 1205 waitAndTypeByXpath("//input[@id='document.documentHeader.documentDescription']", "Validation Test State"); 1206 assertBlanketApproveButtonsPresent(); 1207 //waitAndClick("methodToCall.performLookup.(!!org.kuali.rice.location.impl.country.CountryBo!!).(((code:document.newMaintainableObject.countryCode,))).((`document.newMaintainableObject.countryCode:code,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" + getBaseUrlString() + "/kr/lookup.do;::::).anchor4"); 1208 String countryLookUp = "//input[@name='methodToCall.performLookup.(!!org.kuali.rice.location.impl.country.CountryBo!!).(((code:document.newMaintainableObject.countryCode,))).((`document.newMaintainableObject.countryCode:code,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" 1209 + getBaseUrlString() + "/kr/lookup.do;::::).anchor4']"; 1210 waitAndClickByXpath(countryLookUp); 1211 waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']"); 1212 waitAndClickByLinkText("return value"); 1213 String code = RandomStringUtils.randomAlphabetic(2).toUpperCase(); 1214 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.code']", code); 1215 String state = "Validation Test State " + code; 1216 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", state); 1217 waitAndClickByXpath("//input[@id='document.newMaintainableObject.active']"); 1218 blanketApproveTest(); 1219 assertDocFinal(docId); 1220 } 1221 1222 protected void testReferenceCampusTypeBlanketApprove() throws Exception { 1223 // open(ITUtil.getBaseUrlString() + getTestUrl()); 1224 selectFrame("iframeportlet"); 1225 waitAndCreateNew(); 1226 String docId = waitForDocId(); 1227 assertBlanketApproveButtonsPresent(); 1228 waitAndTypeByXpath("//input[@id='document.documentHeader.documentDescription']", "Validation Test Campus Type " 1229 + ITUtil.DTS_TWO); 1230 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.code']", RandomStringUtils.randomAlphabetic(2)); 1231 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", "Indianapolis" + ITUtil.DTS_TWO); 1232 blanketApproveTest(); 1233 assertDocFinal(docId); 1234 } 1235 1236 protected void testWorkFlowDocTypeBlanketApprove() throws Exception { 1237 // open(ITUtil.getBaseUrlString() + getTestUrl()); 1238 selectFrame("iframeportlet"); 1239 waitAndCreateNew(); 1240 String docId = waitForDocId(); 1241 assertBlanketApproveButtonsPresent(); 1242 waitAndTypeByXpath("//input[@id='document.documentHeader.documentDescription']", 1243 "Validation Test Document Type " + ITUtil.DTS); 1244 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,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" 1245 + getBaseUrlString() + "/kr/lookup.do;::::).anchor4']"; 1246 waitAndClickByXpath(parentDocType); 1247 waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']"); 1248 waitAndClickByLinkText("return value"); 1249 String docTypeName = "DocType" + ITUtil.DTS; 1250 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", docTypeName); 1251 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.unresolvedDocHandlerUrl']", 1252 "${kr.url}/maintenance.do?methodToCall=docHandler"); 1253 //waitAndTypeByXpath("//input[@id='document.newMaintainableObject.actualNotificationFromAddress']", "NFA"); 1254 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.label']", 1255 "Workflow Maintenance Document Type Document"); 1256 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.unresolvedHelpDefinitionUrl']", 1257 "default.htm?turl=WordDocuments%2Fdocumenttype.htm"); 1258 blanketApproveTest(); 1259 assertDocFinal(docId); 1260 } 1261 1262 protected void testVerifyAddDeleteNoteLegacy() throws Exception { 1263 selectFrame("iframeportlet"); 1264 waitAndClick("div.tableborders.wrap.uif-boxLayoutVerticalItem.clearfix span.uif-headerText-span > img.uif-disclosure-image"); 1265 waitForElementPresent("button[title='Add a Note'].uif-action.uif-primaryActionButton.uif-smallActionButton"); 1266 waitAndClickByName("newCollectionLines['document.notes'].noteText"); 1267 waitAndTypeByName("newCollectionLines['document.notes'].noteText", "Test note"); 1268 waitAndClick("button[title='Add a Note'].uif-action.uif-primaryActionButton.uif-smallActionButton"); 1269 waitForElementPresentByName("document.notes[0].noteText"); 1270 1271 assertEquals("Test note", getTextByXpath("//pre")); 1272 waitAndClick("button[title='Delete a Note'].uif-action.uif-primaryActionButton.uif-smallActionButton"); 1273 assertEquals(Boolean.FALSE, isElementPresentByName("document.notes[0].noteText")); 1274 passed(); 1275 } 1276 1277 protected void testVerifyAdHocRecipientsLegacy() throws Exception { 1278 selectFrame("iframeportlet"); 1279 waitAndClickByLinkText("Fiscal Officer Accounts"); 1280 1281 assertElementPresentByXpath("//select[@name=\"newCollectionLines['document.adHocRoutePersons'].actionRequested\"]"); 1282 assertElementPresentByXpath("//input[@name=\"newCollectionLines['document.adHocRoutePersons'].name\" and @type=\"text\"]"); 1283 1284 assertElementPresentByXpath("//select[@name=\"newCollectionLines['document.adHocRouteWorkgroups'].actionRequested\"]"); 1285 assertElementPresentByXpath("//input[@name=\"newCollectionLines['document.adHocRouteWorkgroups'].recipientNamespaceCode\" and @type='text']"); 1286 assertElementPresentByXpath("//input[@name=\"newCollectionLines['document.adHocRouteWorkgroups'].recipientName\" and @type='text']"); 1287 passed(); 1288 } 1289 1290 protected void testVerifyButtonsLegacy() throws Exception { 1291 selectFrame("iframeportlet"); 1292 assertElementPresentByXpath("//button[contains(.,'ubmit')]"); 1293 assertElementPresentByXpath("//button[contains(.,'ave')]"); 1294 assertElementPresentByXpath("//button[contains(.,'lanket approve')]"); 1295 assertElementPresentByXpath("//button[contains(.,'lose')]"); 1296 assertElementPresentByXpath("//a[contains(.,'ancel')]"); 1297 passed(); 1298 } 1299 1300 protected void testVerifyConstraintText() throws Exception { 1301 selectFrame("iframeportlet"); 1302 assertEquals( 1303 "* indicates required field", 1304 getText("div.uif-boxLayout.uif-horizontalBoxLayout.clearfix > span.uif-message.uif-requiredInstructionsMessage.uif-boxLayoutHorizontalItem")); 1305 1306 assertEquals( 1307 "Must not be more than 10 characters", 1308 getText("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")); 1309 1310 assertEquals( 1311 "Must not be more than 10 characters", 1312 getText("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")); 1313 1314 assertEquals( 1315 "Must not be more than 10 characters", 1316 getText("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")); 1317 passed(); 1318 } 1319 1320 protected void testVerifyDisclosures() throws Exception { 1321 selectFrame("iframeportlet"); 1322 assertElementPresentByXpath("//span[contains(text(),'Document Overview')]"); 1323 assertElementPresentByXpath("//span[contains(text(),'Document Overview')]"); 1324 assertElementPresentByXpath("//span[contains(text(),'Account Information')]"); 1325 assertElementPresentByXpath("//span[contains(text(),'Fiscal Officer Accounts')]"); 1326 assertElementPresentByXpath("//span[contains(text(),'Notes and Attachments')]"); 1327 assertElementPresentByXpath("//span[contains(text(),'Ad Hoc Recipients')]"); 1328 assertElementPresentByXpath("//span[contains(text(),'Route Log')]"); 1329 1330 colapseExpandByXpath("//span[contains(text(),'Document Overview')]//img", 1331 "//label[contains(text(),'Organization Document Number')]"); 1332 colapseExpandByXpath("//span[contains(text(),'Account Information')]//img", 1333 "//label[contains(text(),'Travel Account Type Code')]"); 1334 colapseExpandByXpath("//span[contains(text(),'Fiscal Officer Accounts')]//img", 1335 "//a[contains(text(),'Lookup/Add Multiple Lines')]"); 1336 1337 expandColapseByXpath("//span[contains(text(),'Notes and Attachments')]//img", 1338 "//label[contains(text(),'Note Text')]"); 1339 expandColapseByXpath("//span[contains(text(),'Ad Hoc Recipients')]", 1340 "//span[contains(text(),'Ad Hoc Group Requests')]"); 1341 1342 // Handle frames 1343 waitAndClickByXpath("//span[contains(text(),'Route Log')]//img"); 1344 selectFrame("routeLogIFrame"); 1345 1346 waitIsVisibleByXpath("//img[@alt='refresh']"); 1347 1348 // relative=top iframeportlet might look weird but either alone results in something not found. 1349 selectTopFrame(); 1350 selectFrame("iframeportlet"); 1351 waitAndClickByXpath("//span[contains(text(),'Route Log')]//img"); 1352 selectFrame("routeLogIFrame"); 1353 1354 waitNotVisibleByXpath("//img[@alt='refresh']"); 1355 passed(); 1356 } 1357 1358 protected void testVerifyDocumentOverviewLegacy() throws Exception { 1359 selectFrame("iframeportlet"); 1360 assertTextPresent("Document Overview"); 1361 assertElementPresentByXpath("//input[@name='document.documentHeader.documentDescription']"); 1362 assertElementPresentByXpath("//input[@name='document.documentHeader.organizationDocumentNumber']"); 1363 assertElementPresentByXpath("//textarea[@name='document.documentHeader.explanation']"); 1364 passed(); 1365 } 1366 1367 protected void testVerifyExpandCollapse() throws Exception { 1368 selectFrame("iframeportlet"); 1369 assertElementPresentByXpath("//button[contains(@class, 'uif-expandDisclosuresButton')]"); 1370 assertElementPresentByXpath("//button[contains(@class, 'uif-collapseDisclosuresButton')]"); 1371 passed(); 1372 } 1373 1374 protected void testVerifyFieldsLegacy() throws Exception { 1375 selectFrame("iframeportlet"); 1376 assertElementPresentByXpath("//input[@name='document.newMaintainableObject.dataObject.number' and @type='text' and @size=10 and @maxlength=10]"); 1377 assertElementPresentByXpath("//input[@name='document.newMaintainableObject.dataObject.extension.accountTypeCode' and @type='text' and @size=2 and @maxlength=3]"); 1378 assertElementPresentByXpath("//input[@name='document.newMaintainableObject.dataObject.subAccount' and @type='text' and @size=10 and @maxlength=10]"); 1379 assertElementPresentByXpath("//input[@name='document.newMaintainableObject.dataObject.subsidizedPercent' and @type='text' and @size=6 and @maxlength=20]"); 1380 assertElementPresentByXpath("//input[@name='document.newMaintainableObject.dataObject.foId' and @type='text' and @size=5 and @maxlength=10]"); 1381 assertElementPresentByXpath("//input[@name=\"newCollectionLines['document.newMaintainableObject.dataObject.fiscalOfficer.accounts'].number\" and @type='text' and @size=10 and @maxlength=10]"); 1382 assertElementPresentByXpath("//input[@name=\"newCollectionLines['document.newMaintainableObject.dataObject.fiscalOfficer.accounts'].foId\" and @type='text' and @size=5 and @maxlength=10]"); 1383 passed(); 1384 } 1385 1386 protected void testVerifyHeaderFieldsLegacy() throws Exception { 1387 selectFrame("iframeportlet"); 1388 assertElementPresentByXpath("//div[contains(@class, 'uif-documentNumber')]"); 1389 assertElementPresentByXpath("//div[contains(@class, 'uif-documentInitiatorNetworkId')]"); 1390 assertElementPresentByXpath("//div[contains(@class, 'uif-documentStatus')]"); 1391 assertElementPresentByXpath("//div[contains(@class, 'uif-documentCreateDate')]"); 1392 passed(); 1393 } 1394 1395 protected void testVerifyLookupAddMultipleLinesLegacy() throws Exception { 1396 selectFrame("iframeportlet"); 1397 assertElementPresentByXpath("//a[contains(text(),'Lookup/Add Multiple Lines')]"); 1398 passed(); 1399 } 1400 1401 protected void testVerifyNotesAndAttachments() throws Exception { 1402 selectFrame("iframeportlet"); 1403 waitAndClickByXpath("//span[contains(text(),'Notes and Attachments')]"); 1404 waitForElementPresentByXpath("//button[@title='Add a Note']"); 1405 assertElementPresentByXpath("//span[contains(text(),'Notes and Attachments')]"); 1406 assertElementPresentByXpath("//textarea[@name=\"newCollectionLines['document.notes'].noteText\"]"); 1407 assertElementPresentByXpath("//input[@name='attachmentFile']"); 1408 //assertElementPresentByXpath("//input[@name=\"newCollectionLines['document.notes'].attachment.attachmentTypeCode\"]"); 1409 passed(); 1410 } 1411 1412 protected void testVerifyQuickfinderIconsLegacy() throws Exception { 1413 selectFrame("iframeportlet"); 1414 assertTextPresent("Document Overview"); 1415 assertElementPresentByXpath("//*[@id='quickfinder1']"); 1416 assertElementPresentByXpath("//*[@id='quickfinder2']"); 1417 assertElementPresentByXpath("//*[@id='quickfinder3']"); 1418 assertElementPresentByXpath("//*[@id='quickfinder4_add']"); 1419 // TODO it would be better to test that the image isn't 404 1420 passed(); 1421 } 1422 1423 protected void testVerifyRouteLog() throws Exception { 1424 selectFrame("iframeportlet"); 1425 waitAndClickByLinkText("Route Log"); 1426 waitForElementPresent("//iframe[contains(@src,'RouteLog.do')]"); 1427 passed(); 1428 } 1429 1430 protected void testVerifySave() throws Exception { 1431 selectFrame("iframeportlet"); 1432 waitAndTypeByName("document.documentHeader.documentDescription", "Test Document " + ITUtil.DTS); 1433 waitAndClickByName("document.newMaintainableObject.dataObject.number"); 1434 waitAndTypeByName("document.newMaintainableObject.dataObject.number", "1234567890"); 1435 waitAndTypeByName("document.newMaintainableObject.dataObject.extension.accountTypeCode", "EAT"); 1436 waitAndTypeByName("document.newMaintainableObject.dataObject.subAccount", "a1"); 1437 waitAndClick("button[data-loadingmessage='Saving...'].uif-action.uif-primaryActionButton.uif-boxLayoutHorizontalItem"); 1438 Thread.sleep(2000); 1439 // checkErrorMessageItem(" also digit validation jira https://jira.kuali.org/browse/KULRICE-8038"); 1440 passed(); 1441 } 1442 1443 protected void testVerifySubsidizedPercentWatermarkLegacy() throws Exception { 1444 selectFrame("iframeportlet"); 1445 // May be blowing up due to multiple locators 1446 //assertTrue(isElementPresent("//input[@name='document.newMaintainableObject.dataObject.subsidizedPercent' and @type='text' and @placeholder='##.## ']")); 1447 assertElementPresentByXpath("//input[@name='document.newMaintainableObject.dataObject.subsidizedPercent']"); 1448 passed(); 1449 } 1450 1451 private void testLookUp() throws Exception { 1452 waitForPageToLoad(); 1453 selectFrame("iframeportlet"); 1454 // Mixed capitalization 1455 waitAndClick(By.xpath("//button[contains(text(),'Search')]")); 1456 waitAndClickByLinkText("edit", "edit button not present does user " + user + " have permission?"); 1457 checkForIncidentReport("submit"); 1458 assertTextPresent("ubmit"); 1459 assertTextPresent("ave"); 1460 assertTextPresent("pprove"); 1461 assertTextPresent("lose"); 1462 assertTextPresent("ancel"); 1463 1464 } 1465 1466 protected void agendaLookupAssertions() throws Exception { 1467 testLookUp(); 1468 assertTextPresent("Rules"); 1469 waitAndClick(By.xpath("//a[contains(text(), 'Cancel')]")); 1470 passed(); 1471 } 1472 1473 protected void testAttributeDefinitionLookUp() throws Exception { 1474 waitForPageToLoad(); 1475 selectFrame("iframeportlet"); 1476 waitAndClickByXpath("//button[contains(.,'earch')]"); 1477 Thread.sleep(3000); 1478 waitForPageToLoad(); 1479 driver.findElement(By.tagName("body")).getText().contains("Actions"); // there are no actions, but the header is the only unique text from searching 1480 waitAndClickByLinkText("1000"); 1481 waitForPageToLoad(); 1482 1483 driver.findElement(By.tagName("body")).getText().contains("Attribute Inquiry"); 1484 driver.findElement(By.tagName("body")).getText().contains("KRMS Attributes"); 1485 driver.findElement(By.tagName("body")).getText().contains("Attribute Label"); 1486 driver.findElement(By.tagName("body")).getText().contains("1000"); 1487 driver.findElement(By.tagName("body")).getText().contains("peopleFlowId"); 1488 driver.findElement(By.tagName("body")).getText().contains("KR-RULE"); 1489 driver.findElement(By.tagName("body")).getText().contains("PeopleFlow"); 1490 // selectFrame("name=fancybox-frame1343151577256"); // TODO parse source to get name 1491 // waitAndClick("css=button:contains(Close)"); // looks lower case, but is upper 1492 // Thread.sleep(500); 1493 // waitAndClick("css=button:contains(cancel)"); 1494 1495 // AttributeDefinition's don't have actions (yet) 1496 // waitAndClick("id=u80"); 1497 // waitForPageToLoad(); 1498 // waitAndClick("id=u86"); 1499 // waitForPageToLoad(); 1500 // selectWindow("null"); 1501 // waitAndClick("xpath=(//input[@name='imageField'])[2]"); 1502 // waitForPageToLoad(); 1503 passed(); 1504 } 1505 1506 protected void contextLookupAssertions() throws Exception { 1507 testLookUp(); 1508 assertTextPresent("Notes and Attachments"); 1509 waitAndClick(By.xpath("//a[contains(text(), 'Cancel')]")); 1510 passed(); 1511 } 1512 1513 protected void testCreateNewAgenda() throws Exception { 1514 selectFrame("iframeportlet"); 1515 selectByName("document.newMaintainableObject.dataObject.namespace", "Kuali Rules Test"); 1516 String agendaName = "Agenda Date :" + Calendar.getInstance().getTime().toString(); 1517 waitAndTypeByName("document.newMaintainableObject.dataObject.agenda.name", "Agenda " + agendaName); 1518 waitAndTypeByName("document.newMaintainableObject.dataObject.contextName", "Context1"); 1519 fireEvent("document.newMaintainableObject.dataObject.contextName", "blur"); 1520 fireEvent("document.newMaintainableObject.dataObject.contextName", "focus"); 1521 waitForElementPresentByName("document.newMaintainableObject.dataObject.agenda.typeId"); 1522 selectByName("document.newMaintainableObject.dataObject.agenda.typeId", "Campus Agenda"); 1523 waitForElementPresentByName("document.newMaintainableObject.dataObject.customAttributesMap[Campus]"); 1524 waitAndTypeByName("document.newMaintainableObject.dataObject.customAttributesMap[Campus]", "BL"); 1525 waitAndClickByXpath("//div[2]/button"); 1526 waitForPageToLoad(); 1527 waitAndClickByXpath("//div[2]/button[3]"); 1528 waitForPageToLoad(); 1529 selectTopFrame(); 1530 waitAndClickByXpath("(//input[@name='imageField'])[2]"); 1531 passed(); 1532 } 1533 1534 protected void testPeopleFlow() throws Exception { 1535 selectFrame("iframeportlet"); 1536 //Click Main Menu and Create New 1537 // waitAndCreateNew(); 1538 // waitForPageToLoad(); 1539 waitAndClickByLinkText("Create New"); 1540 // waitAndClick(By.linkText("Create New")); 1541 //Save docId 1542 waitForElementPresent("div[data-headerfor='PeopleFlow-MaintenanceView'] div[data-label='Document Number'] > span"); 1543 String docId = getText("div[data-headerfor='PeopleFlow-MaintenanceView'] div[data-label='Document Number'] > span"); 1544 1545 driver.findElement(By.name("document.documentHeader.documentDescription")).clear(); 1546 driver.findElement(By.name("document.documentHeader.documentDescription")).sendKeys("Description for Document"); 1547 new Select(driver.findElement(By.name("document.newMaintainableObject.dataObject.namespaceCode"))) 1548 .selectByVisibleText("KUALI - Kuali Systems"); 1549 driver.findElement(By.name("document.newMaintainableObject.dataObject.name")).clear(); 1550 driver.findElement(By.name("document.newMaintainableObject.dataObject.name")).sendKeys( 1551 "Document Name" + ITUtil.DTS); 1552 1553 //Add Row1 1554 driver.findElement( 1555 By.name("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName")).clear(); 1556 driver.findElement( 1557 By.name("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName")) 1558 .sendKeys("kr"); 1559 driver.findElement(By.cssSelector("button[data-loadingmessage='Adding Line...']")).click(); 1560 Thread.sleep(3000); 1561 //Add Row2 1562 driver.findElement( 1563 By.name("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName")).clear(); 1564 driver.findElement( 1565 By.name("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName")) 1566 .sendKeys("admin"); 1567 driver.findElement(By.cssSelector("button[data-loadingmessage='Adding Line...']")).click(); 1568 Thread.sleep(3000); 1569 1570 //Blanket approve 1571 driver.findElement( 1572 By.cssSelector("div[data-parent='PeopleFlow-MaintenanceView'] > div.uif-footer button~button~button")) 1573 .click(); 1574 Thread.sleep(5000); 1575 //Close the Doc 1576 // driver.findElement(By.id("uif-close")).click(); 1577 // Thread.sleep(3000); 1578 1579 driver.switchTo().window(driver.getWindowHandles().toArray()[0].toString()); 1580 driver.findElement(By.cssSelector("img[alt=\"doc search\"]")).click(); 1581 Thread.sleep(5000); 1582 1583 selectFrame("iframeportlet"); 1584 driver.findElement(By.cssSelector("td.infoline > input[name=\"methodToCall.search\"]")).click(); 1585 Thread.sleep(5000); 1586 assertEquals("FINAL", driver.findElement(By.xpath("//table[@id='row']/tbody/tr/td[4]")).getText()); 1587 driver.switchTo().defaultContent(); 1588 driver.findElement(By.name("imageField")).click(); 1589 1590 } 1591 1592 protected void testTermLookupAssertions() throws Exception { 1593 testLookUp(); 1594 assertTextPresent("Term Parameters"); 1595 waitAndClick(By.xpath("//a[contains(text(), 'Cancel')]")); 1596 passed(); 1597 } 1598 1599 protected void testTermSpecificationLookupAssertions() throws Exception { 1600 testLookUp(); 1601 assertTextPresent("Context"); 1602 waitAndClick(By.xpath("//a[contains(text(), 'Cancel')]")); 1603 passed(); 1604 } 1605 1606 }