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