View Javadoc
1   /**
2    * Copyright 2005-2016 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.testtools.selenium;
17  
18  import org.openqa.selenium.Keys;
19  
20  import org.apache.commons.lang.RandomStringUtils;
21  import org.junit.Before;
22  import org.kuali.rice.testtools.common.JiraAwareFailable;
23  import org.kuali.rice.testtools.common.JiraAwareFailureUtils;
24  import org.kuali.rice.testtools.common.PropertiesUtils;
25  import org.openqa.selenium.By;
26  import org.openqa.selenium.WebElement;
27  
28  import java.io.IOException;
29  import java.text.SimpleDateFormat;
30  import java.util.ArrayList;
31  import java.util.Calendar;
32  import java.util.HashMap;
33  import java.util.List;
34  import java.util.Map;
35  import java.util.concurrent.TimeUnit;
36  
37  /**
38   * <p>
39   * Old rice sampleapp AFT code.  New KRAD AFT code should go in WebDriverAftBase (or maybe KradAftBase in the future).
40   * </p>
41   * <p>
42   * Originally used to upgrade UpgradedSeleniumITBase (Selenium 1.0) tests to WebDriver (Selenium 2.0).  Now there is
43   * refactoring to be done:
44   * <ol>
45   *   <li><a href="https://jira.kuali.org/browse/KULRICE-9206">KULRICE-9206</a> Replace literal strings used more than 3 times with Constants,
46   *   Javadoc constant with constant value.
47   *   <li>Extract duplicate waitAndClick...(CONSTANT) to waitAndClickConstant, Javadoc a <pre>{@link &#35;CONSTANT}</pre>.
48   *   <li>Replace large chunks of duplication</li>
49   *   <li><a href="https://jira.kuali.org/browse/KULRICE-9205">KULRICE-9205</a> Invert dependencies on fields and extract methods to WebDriverUtils
50   *   so inheritance doesn't have to be used for reuse.  See WebDriverUtils.waitFor </li>
51   *   <li>Extract Nav specific code?</li>
52   *   <li>Rename to SampleAppAftBase</li>
53   * </ol>
54   * </p>
55   * <p>Calls to passed() probably don't belong in the methods reused here.</p>
56   * @author Kuali Rice Team (rice.collab@kuali.org)
57   * @deprecated only rice sampleapp specific code should go in this class, see WebDriverAftBase.
58   */
59  public abstract class WebDriverLegacyITBase extends WebDriverAftBase {
60  
61      /**
62       * Administration
63       */
64      public static final String ADMINISTRATION_LINK_TEXT = "Administration";
65  
66      /**
67       * Agenda Lookup
68       */
69      public static final String AGENDA_LOOKUP_LINK_TEXT = "Agenda Lookup";
70  
71      /**
72       * backdoorId
73       */
74      public static final String BACKDOOR_ID_TEXT = "backdoorId";
75  
76      /**
77       * "//input[@title='Click to login.']"
78       */
79      public static final String BACKDOOR_LOGIN_BUTTON_XPATH = "//input[@title='Click to login.']";
80  
81      /**
82       * methodToCall.blanketApprove
83       */
84      public static final String BLANKET_APPROVE_NAME = "methodToCall.blanketApprove";
85  
86      /**
87       * methodToCall.cancel
88       * different cancel than CANCEL2_XPATH
89       */
90      public static final String CANCEL_NAME = "methodToCall.cancel";
91  
92      /**
93       * //a[contains(text(), 'ancel')]
94       * Different cancel than CANCEL_NAME
95       */
96      public static final String CANCEL2_XPATH = "//a[contains(text(), 'ancel')]";
97  
98      /**
99       * "//a[@title='cancel']"
100      */
101     public static final String CANCEL3_XPATH = "//a[@title='cancel']";
102 
103     /**
104      * //*[@title='close this window']
105      */
106     public static final String CLOSE_WINDOW_XPATH_TITLE = "//*[@title='close this window']";
107 
108     /**
109      * Collections
110      */
111     public static final String COLLECTIONS_LINK_TEXT = "Collections";
112 
113     /**
114      * "Kuali :: Configuration Test View"
115      */
116     public static final String CONFIGURATION_VIEW_WINDOW_TITLE = "Kuali :: Configuration Test View";
117 
118     /**
119      * (//a[contains(text(),'Configuration Test View')])[3]
120      */
121     public static final String CONFIGURATION_VIEW_XPATH = "(//a[contains(text(),'Configuration Test View')])";
122 
123     /**
124      * copy
125      */
126     public static final String COPY_LINK_TEXT = "copy";
127 
128     /**
129      * New Document not submitted successfully
130      */
131     public static final String CREATE_NEW_DOCUMENT_NOT_SUBMITTED_SUCCESSFULLY_MESSAGE_TEXT = "New Document not submitted successfully";
132 
133     /**
134      * //img[@alt='create new']
135      */
136     public static final String CREATE_NEW_XPATH = "//img[@alt='create new']";
137 
138     /**
139      * //a[@title='Create a new record']
140      */
141     public static final String CREATE_NEW_XPATH2 = "//a[@title='Create a new record']";
142 
143     /**
144      * div.dataTables_wrapper thead th
145      */
146     public static final String DATA_TABLE_TR_CSS = "div.dataTables_wrapper tbody tr";
147 
148     /**
149      * //div[@class='error']"
150      */
151     public static final String DIV_ERROR_LOCATOR = "//div[@class='error']";
152 
153     /**
154      * //div[@class='error']"
155      */
156     public static final String DIV_ERROR_LOCATOR_KRAD = "//div[@class='alert alert-danger']/ul";
157 
158     /**
159      * //div[@class='msg-excol']
160      */
161     public static final String DIV_EXCOL_LOCATOR = "//div[@class='msg-excol']";
162 
163     /**
164      * //div[@class='left-errmsg-tab']/div/div
165      */
166     public static final String DIV_LEFT_ERRMSG = "//div[@class='left-errmsg-tab']/div/div";
167 
168     /**
169      * //input[@id='document.newMaintainableObject.code']
170      */
171     public static final String DOC_CODE_XPATH = "//input[@id='document.newMaintainableObject.code']";
172 
173     /**
174      * //div[@id='headerarea']/div/table/tbody/tr[1]/td[1]
175      */
176     public static final String DOC_ID_XPATH = "//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]";
177 
178     /**
179      * //div[@id='headerarea']/div/table/tbody/tr[1]/td[1]
180      */
181     public static final String DOC_ID_KRAD_XPATH = "//div[@data-label=\"Document Number\"]";
182     /**
183      * //table[@id='row']/tbody/tr[1]/td[1
184      */
185     public static final String DOC_ID_XPATH_2 = "//table[@id='row']/tbody/tr[1]/td[1]";
186 
187     /**
188      * //table[@id='row']/tbody/tr[1]/td[1]/a
189      */
190     public static final String DOC_ID_XPATH_3 ="//table[@id='row']/tbody/tr[1]/td[1]/a";
191 
192     /**
193      * //input[@id='document.documentHeader.documentDescription']
194      */
195     public static final String DOC_DESCRIPTION_XPATH ="//input[@id='document.documentHeader.documentDescription']";
196 
197     /**
198      * //div[@id='headerarea']/div/table/tbody/tr[1]/td[1]
199      */
200     public static final String DOC_INITIATOR_XPATH = "//div[@id='headerarea']/div/table/tbody/tr[2]/td[1]";
201 
202     /**
203      * "//img[@alt='doc search']
204      */
205     public static final String DOC_SEARCH_XPATH = "//img[@alt='doc search']";
206 
207     /**
208      * //a[@title='Document Search']
209      */
210     public static final String DOC_SEARCH_XPATH_TITLE = "//a[@title='Document Search']";
211 
212     /**
213      * ENROUTE
214      */
215     public static final String DOC_STATUS_ENROUTE = "ENROUTE";
216 
217     /**
218      * FINAL
219      */
220     public static final String DOC_STATUS_FINAL = "FINAL";
221 
222     /**
223      * SAVED
224      */
225     public static final String DOC_STATUS_SAVED = "SAVED";
226 
227     /**
228      * //table[@class='headerinfo']//tr[1]/td[2]
229      */
230     public static final String DOC_STATUS_XPATH = "//table[@class='headerinfo']//tr[1]/td[2]";
231 
232     /**
233      * //table[@id='row']/tbody/tr[1]/td[4]
234      */
235     public static final String DOC_STATUS_XPATH_2 = "//table[@id='row']/tbody/tr[1]/td[4]";
236 
237     /**
238      * //div[contains(div,'Document was successfully submitted.')]
239      */
240     public static final String DOC_SUBMIT_SUCCESS_MSG_XPATH ="//div[contains(div,'Document was successfully submitted.')]";
241 
242     /**
243      * edit
244      */
245     public static final String EDIT_LINK_TEXT = "edit";
246 
247     /**
248      * iframeportlet
249      */
250     public static final String IFRAMEPORTLET_NAME = "iframeportlet";
251 
252     /**
253      * (//a[contains(text(),'Uif Components (Kitchen Sink)')])[2]
254      */
255     public static final String KITCHEN_SINK_XPATH = "(//a[contains(text(),'Uif Components (Kitchen Sink)')])";
256 
257     /**
258      * KRAD
259      */
260     public static final String KRAD_XPATH = "KRAD";
261 
262     /**
263      * Kuali :: Collection Totaling
264      */
265     public static final String KUALI_COLLECTION_TOTALLING_WINDOW_XPATH = "Kuali :: Collection Totaling";
266 
267     /**
268      * //a[text()='Collection Totaling']
269      */
270     public static final String KUALI_COLLECTION_TOTALLING_XPATH = "//a[text()='Collection Totaling']";
271 
272     /**
273      * Kuali :: Uif Components
274      */
275     public static final String KUALI_UIF_COMPONENTS_WINDOW_XPATH = "Kuali :: Uif Components";
276 
277     /**
278      * "Kuali :: View Title"
279      */
280     public static final String KUALI_VIEW_WINDOW_TITLE = "Kuali :: View Title";
281 
282     /**
283      * KUALI - Kuali Systems
284      */
285     public static final String LABEL_KUALI_KUALI_SYSTEMS = "KUALI - Kuali Systems";
286 
287     /**
288      * KUALI : Default
289      */
290     public static final String LABEL_KUALI_DEFAULT = "KUALI : Default";
291 
292     /**
293      * //input[@name='imageField' and @value='Logout']
294      */
295     public static final String LOGOUT_XPATH = "//input[@name='imageField' and @value='Logout']";
296 
297     /**
298      * Main Menu
299      */
300     public static final String MAIN_MENU_LINK_TEXT = "Main Menu";
301 
302     /**
303      * Kuali :: Rich Messages
304      */
305     public static final String RICH_MESSAGES_WINDOW_TITLE = "Kuali :: Rich Messages";
306 
307     /**
308      * //div[contains(div,'Document was successfully saved.')]
309      */
310     public static final String SAVE_SUCCESSFUL_XPATH = "//div[contains(div,'Document was successfully saved.')]";
311 
312     /**
313      * //input[@name='methodToCall.save' and @alt='save']
314      */
315     public static final String SAVE_XPATH="//input[@name='methodToCall.save' and @alt='save']";
316 
317     /**
318      * KIM Screens
319      * //*[@name='methodToCall.save' and @alt='save']
320      */
321     public static final String SAVE_XPATH_2 = "//*[@name='methodToCall.save' and @alt='save']";
322 
323     /**
324      * KIM Screens
325      * //*[@name='methodToCall.reload' and @alt='reload']
326      */
327     public static final String RELOAD_XPATH = "//*[@name='methodToCall.reload' and @alt='reload']";
328 
329     /**
330      * //input[@title='search' and @name='methodToCall.search']
331      */
332     public static final String SAVE_XPATH_3 = "//input[@title='search' and @name='methodToCall.search']";
333 
334     /**
335      * Search
336      */
337     public static final String SEARCH = "Search";
338 
339     /**
340      * //input[@name='methodToCall.search' and @value='search']
341      */
342     public static final String SEARCH_XPATH="//input[@name='methodToCall.search' and @value='search']";
343 
344     /**
345      * //input[@value='search']
346      */
347     public static final String SEARCH_XPATH_2 = "//input[@value='search']";
348 
349     /**
350      * (//input[@name='methodToCall.search'])[2]
351      */
352     public static final String SEARCH_SECOND = "(//input[@name='methodToCall.search'])[2]";
353 
354     /**
355      * //input[@name='methodToCall.route' and @alt='submit']
356      */
357     public static final String SUBMIT_XPATH="//input[@name='methodToCall.route' and @alt='submit']";
358 
359     /**
360      * //input[@name='methodToCall.approve' and @alt='approve']
361      */
362     public static final String APPROVE_XPATH="//input[@name='methodToCall.approve' and @alt='approve']";
363 
364     /**
365      * //input[@name='methodToCall.disapprove' and @alt='disapprove']
366      */
367     public static final String DISAPPROVE_XPATH="//input[@name='methodToCall.disapprove' and @alt='disapprove']";
368 
369     /**
370      * //input[@name='methodToCall.acknowledge' and @alt='acknowledge']
371      */
372     public static final String ACKNOWLEDGE_XPATH="//input[@name='methodToCall.acknowledge' and @alt='acknowledge']";
373 
374     /**
375      * //input[@name='methodToCall.close' and @alt='close']
376      */
377     public static final String CLOSE_XPATH="//input[@name='methodToCall.close' and @alt='close']";
378 
379     /**
380      * Travel Account Lookup
381      */
382     public static final String TRAVEL_ACCOUNT_LOOKUP_LINK_TEXT = "Travel Account Lookup";
383 
384     /**
385      * Uif Components (Kitchen Sink)
386      */
387     public static final String UIF_COMPONENTS_KITCHEN_SINK_LINK_TEXT = "Uif Components (Kitchen Sink)";
388 
389     /**
390      * (//a[contains(text(),'Validation Framework Demo')])[2]
391      */
392     public static final String VALIDATION_FRAMEWORK_DEMO_XPATH = "(//a[contains(text(),'Validation Framework Demo')])";
393 
394     /**
395      * XML Ingester
396      */
397     public static final String XML_INGESTER_LINK_TEXT = "XML Ingester";
398 
399     /**
400      * //a[@title='FiscalOfficerInfo Maintenance (New)']
401      */
402     public static final String FISCAL_OFFICER_INFO_MAINTENANCE_NEW_XPATH = "//a[@title='FiscalOfficerInfo Maintenance (New)']";
403 
404     static {
405         if (System.getProperty(WebDriverUtils.REMOTE_PROPERTIES_PROPERTY) != null) {
406             PropertiesUtils propUtils = new PropertiesUtils();
407             try {
408                 propUtils.loadPropertiesWithSystemAndOverridesIntoSystem(System.getProperty(WebDriverUtils.REMOTE_PROPERTIES_PROPERTY));
409             } catch (IOException ioe) {
410                 System.out.println("Exception opening " + System.getProperty(WebDriverUtils.REMOTE_PROPERTIES_PROPERTY) + " " + ioe.getMessage());
411             }
412         }
413     }
414 
415     protected String namespaceCode = "KR-WKFLW";
416 
417     protected String uiFramework = AutomatedFunctionalTestUtils.REMOTE_UIF_KNS;   // default to KNS
418 
419     private static final Map<String, String> actionRequestLabelMap;
420     private static Map<String, String> actionRequestButtonMap;
421     static{
422         actionRequestLabelMap = new HashMap();
423         actionRequestLabelMap.put("A","APPROVE");
424         actionRequestLabelMap.put("F","FYI");
425         actionRequestLabelMap.put("C","COMPLETE");
426         actionRequestLabelMap.put("CR","COMPLETE");
427         actionRequestLabelMap.put("K","ACKNOWLEDGE");
428         actionRequestLabelMap.put("D","APPROVE");
429         actionRequestButtonMap = new HashMap();
430         actionRequestButtonMap.put("A","methodToCall.approve");
431         actionRequestButtonMap.put("F","methodToCall.fyi");
432         actionRequestButtonMap.put("C","methodToCall.complete");
433         actionRequestButtonMap.put("CR","methodToCall.route");
434         actionRequestButtonMap.put("K","methodToCall.acknowledge");
435         actionRequestButtonMap.put("D","methodToCall.disapprove");
436     }
437 
438     /**
439      * Failures in testSetup cause the test to not be recorded.  Future plans are to extract form @Before and call at the start of each test.
440      * Setup the WebDriver properties, test, and login.  Named testSetUp so it runs after TestNG's startSession(Method)
441      * {@link WebDriverUtils#determineUser(String)}
442      * {@link WebDriverUtils#setUp(String, String, String, String)}
443      */
444     @Before
445     public void testSetUp() {
446         super.testSetUp();
447     }
448 
449     /**
450      * // https://jira.kuali.org/browse/KULRICE-9804 KNS Create new link absent when Bookmark URL requires Login
451      * @return
452      */
453     @Override
454     protected String getTestUrl() {
455         String testUrl = super.getTestUrl();
456         if (testUrl.contains(AutomatedFunctionalTestUtils.HIDE_RETURN_LINK) &&
457                 !testUrl.contains("&showMaintenanceLinks=true")) {
458             testUrl += "&showMaintenanceLinks=true";
459         }
460         return testUrl;
461     }
462 
463 
464     protected void impersonateUser(String user) throws InterruptedException {
465         waitAndTypeByName(BACKDOOR_ID_TEXT,user);
466         jGrowl("Click Backdoor Login");
467         waitAndClickByXpath(BACKDOOR_LOGIN_BUTTON_XPATH);
468     }
469 
470     protected void addAdHocRecipientsGroup(String[] adHocRecipients) throws InterruptedException {
471         addAdHocRecipientsGroup(new String[][]{adHocRecipients});
472     }
473 
474     protected void addAdHocRecipientsGroup(String[][] adHocRecipients) throws InterruptedException {
475         String today = getDateToday();
476         Calendar nextYearCal = Calendar.getInstance();
477         nextYearCal.add(Calendar.YEAR, 1);
478         SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
479         String nextYear = sdf.format(nextYearCal.getTime());
480 
481         waitAndClickByName("methodToCall.toggleTab.tabAdHocRecipients");
482         for (int i = 0, s = adHocRecipients.length; i < s; i++) {
483             selectOptionByName("newAdHocRouteWorkgroup.actionRequested", adHocRecipients[i][1]);
484             waitAndTypeByName("newAdHocRouteWorkgroup.recipientName", adHocRecipients[i][0]);
485             waitAndTypeByName("newAdHocRouteWorkgroup.recipientNamespaceCode", adHocRecipients[i][2]);
486             WebDriverUtils.jGrowl(getDriver(), "Click Add Group", false, "Click Add Group");
487             waitAndClickByName("methodToCall.insertAdHocRouteWorkgroup");
488         }
489     }
490 
491     /**
492      * @param adHocRecipients user, action option value
493      * @throws InterruptedException
494      */
495     protected void addAdHocRecipientsPerson(String[] adHocRecipients) throws InterruptedException {
496         addAdHocRecipientsPerson(new String[][]{adHocRecipients});
497     }
498 
499     /**
500      * @param adHocRecipients user, action option value
501      * @throws InterruptedException
502      */
503     protected void addAdHocRecipientsPerson(String[][] adHocRecipients) throws InterruptedException {
504         String today = getDateToday();
505         Calendar nextYearCal = Calendar.getInstance();
506         nextYearCal.add(Calendar.YEAR, 1);
507         SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
508         String nextYear = sdf.format(nextYearCal.getTime());
509 
510         if (!isVisible(By.name("newAdHocRoutePerson.actionRequested"))) {
511             waitAndClickByName("methodToCall.toggleTab.tabAdHocRecipients");
512         }
513         for (int i = 0, s = adHocRecipients.length; i < s; i++) {
514             selectOptionByName("newAdHocRoutePerson.actionRequested", adHocRecipients[i][1]);
515             waitAndTypeByName("newAdHocRoutePerson.id", adHocRecipients[i][0]);
516 //            if (isElementPresentByName("member.activeFromDate")) {
517 //                waitAndTypeByName("member.activeFromDate", today);
518 //            }
519 //            if (isElementPresentByName("member.activeFromDate")) {
520 //                waitAndTypeByName("member.activeFromDate", nextYear);
521 //            }
522             WebDriverUtils.jGrowl(getDriver(), "Click Add Person", false, "Click Add Person");
523             waitAndClickByName("methodToCall.insertAdHocRoutePerson");
524         }
525     }
526 
527     protected void agendaLookupAssertions() throws Exception {
528         testLookUp();
529         assertTextPresent("Rules");
530         waitAndClickCancelByText();
531     }
532 
533     protected void assertActionList(String docId, String actionListOptionValue, String state) throws InterruptedException {
534         selectTopFrame();
535         waitAndClickActionList();
536         selectFrameIframePortlet();
537         while (!waitForIsTextPresent(docId)) {
538             waitAndClickByLinkText("Next");
539         }
540         WebElement docIdTr = findElement(By.xpath("//table/tbody/tr/td/a[contains(text(), '" + docId + "')]/../.."));
541         assertTrue(docIdTr.getText() + " does not contain " + docId, docIdTr.getText().contains(docId));
542         assertTrue(docIdTr.getText() + " does not contain " + state, docIdTr.getText().contains(state));
543         assertTrue(docIdTr.getText() + " does not contain " + actionRequestLabelMap.get(actionListOptionValue), docIdTr.getText().contains(actionRequestLabelMap.get(actionListOptionValue)));
544 //        assertTextPresent(new String[]{docId, actionRequestLabelMap.get(actionListOptionValue)});
545         waitAndClickLinkContainingText(docId);
546         selectChildWindow();
547         waitAndClickByName(actionRequestButtonMap.get(actionListOptionValue));
548 
549         // Disapprove requires another step before checking outbox
550         if ("D".equals(actionListOptionValue)) {
551             waitAndTypeByName("reason","disapproved for AFT");
552             jGrowl("Click yes button");
553             waitAndClickByName("methodToCall.processAnswer.button0");
554         } else if ("C".equals(actionListOptionValue) || "CR".equals(actionListOptionValue)) {
555             waitAndClickByName("methodToCall.close");
556         }
557         waitForTextNotPresent(docId);
558     }
559 
560     protected void assertNotInActionList(String docId) throws InterruptedException {
561         selectTopFrame();
562         waitAndClickActionList();
563         selectFrameIframePortlet();
564         waitForTextNotPresent(docId);
565         while (isElementPresentByLinkText("Next")) {
566             waitAndClickByLinkText("Next");
567             waitForTextNotPresent(docId);
568         }
569     }
570 
571     protected void assertOutbox(String docId, String state) throws InterruptedException {
572         // find it in outbox
573         waitAndClickLinkContainingText("Outbox");
574         // TODO if the docId is present as part of uniqueString there will be a false negative it would be better if there
575         // was a waitForIsElementPresent
576         while (!waitForIsTextPresent(docId)) {
577             waitAndClickByLinkText("Next");
578         }
579         WebElement docIdTr = findElement(By.xpath("//table/tbody/tr/td/a[contains(text(), '" + docId + "')]/../.."));
580         assertTrue("Outbox items " + docIdTr.getText() + " does not contain " + docId, docIdTr.getText().contains(docId));
581         assertTrue("Outbox items " + docIdTr.getText() + " state is incorrect " + state, docIdTr.getText().contains(state));
582         waitForTextPresent(docId);
583 
584 //        // clear all items in the outbox
585 //        waitAndClickAllByName("outboxItems");
586 //        waitAndClickByName("methodToCall.removeOutboxItems");
587     }
588 
589     protected void assertBlanketApproveButtonsPresent() {
590         assertElementPresentByName("methodToCall.route");
591         assertElementPresentByName("methodToCall.save");
592         assertElementPresentByName(BLANKET_APPROVE_NAME, "Blanket Approve button not present does " + user + " have permssion?");
593         assertElementPresentByName("methodToCall.close");
594         assertElementPresentByName(CANCEL_NAME);
595     }
596 
597     protected void assertDocFinal(String docId) throws InterruptedException {
598         assertDocSearch(docId, DOC_STATUS_FINAL);
599     }
600 
601     protected void assertDocSearch(String docId, String docStatus) throws InterruptedException {
602         docSearch(docId);
603         waitForElementPresentByXpath(DOC_ID_XPATH_3);
604         jGrowl("Is doc status for docId: " + docId + " " + docStatus + "?");
605         acceptAlertIfPresent(); // Agenda
606         assertEquals(docId, getTextByXpath(DOC_ID_XPATH_3));
607         assertEquals(docStatus, getTextByXpath(DOC_STATUS_XPATH_2));
608     }
609 
610     protected void docSearch(String docId) throws InterruptedException {
611         selectParentWindow();
612         selectTopFrame();
613         waitAndClickDocSearchTitle();
614         acceptAlertIfPresent(); // Agenda
615         waitForPageToLoad();
616         selectFrameIframePortlet();
617         waitAndTypeByName("documentId", docId);
618         waitAndClickSearch();
619     }
620 
621     protected void assertDocSearchNoResults(String docId) throws InterruptedException {
622         docSearch(docId);
623         waitForTextPresent("No values match this search.");
624     }
625 
626     protected void assertRouteStatus(String status) throws InterruptedException {
627         waitForElementPresentByXpath("//th[contains(.,'Route Status')]/../following-sibling::*/td[contains(.,'" + status + "')]");
628     }
629 
630     protected void assertTableLayout() throws Exception {
631         waitForTextPresent("Actions");
632         String pageSource = driver.getPageSource();
633         assertTrue(pageSource.contains("Table Layout"));
634         assertTrue(pageSource.contains("Field 1"));
635         assertTrue(pageSource.contains("Field 2"));
636         assertTrue(pageSource.contains("Field 3"));
637         assertTrue(pageSource.contains("Field 4"));
638         assertTrue(pageSource.contains("Actions"));
639     }
640 
641     protected void blanketApproveAssert(String docId) throws InterruptedException {
642         checkForDocError();
643         assertDocSearch(docId, DOC_STATUS_FINAL);
644     }
645 
646     protected void blanketApproveCheck() throws InterruptedException {
647         waitAndClickBlanketApproveKns();
648         checkForIncidentReport();
649     }
650 
651     public static String blanketApprovalCleanUpErrorText(String errorText) {
652         errorText = errorText.replace("* required field", "").replace("\n", " ").trim(); // bit of extra ui text we don't care about
653         return errorText;
654     }
655 
656     /**
657      * Tests blanket approve action.
658      * This method is used by several different tests which perform various types of blanket approvals.
659      * Therefore, this is a candidate to remain in this base class
660      *
661      * @throws InterruptedException
662      */
663     protected void blanketApproveTest(String docId) throws InterruptedException {
664         jGrowl("Click Blanket Approve");
665         waitAndClickBlanketApproveKns();
666         Thread.sleep(2000);
667         checkForIncidentReport();
668         blanketApproveAssert(docId);
669     }
670 
671     protected void blanketApproveSuccessfully() throws InterruptedException {
672         waitAndClickBlanketApprove();
673         waitAndClickConfirmBlanketApproveOk();
674         acceptAlertIfPresent(); // LabsLookupDefaultCreateNewBlanketApproveAft
675         waitForProgressLoading();
676         checkForDocErrorKrad();
677         waitForTextPresent("Document was successfully approved.");
678     }
679 
680     protected void failOnErrorMessageItem() {
681         failOnErrorMessageItem(this.getClass().getName());
682     }
683 
684     protected void failOnErrorMessageItem(String message) {
685         final String error_locator = "//li[@class='uif-errorMessageItem']";
686         if (findElements(By.xpath(error_locator)).size() > 0) {
687             String errorText = null;
688 
689             try {
690                 errorText = getTextByXpath(error_locator);
691             } catch (InterruptedException e) {
692                 e.printStackTrace();
693             }
694 
695             if (errorText != null && errorText.contains("errors")) {
696                 jiraAwareFail((errorText + " " + message).trim());
697             }
698 
699         }
700     }
701 
702     /**
703      * Uses Selenium's findElements method which does not throw a test exception if not found.
704      */
705     public void checkForDocError() {
706         if (hasDocError()) {
707             String errorText = extractErrorText();
708             jiraAwareFail(errorText);
709         }
710     }
711 
712     /**
713      * Uses Selenium's findElements method which does not throw a test exception if not found.
714      */
715     public void checkForDocErrorKrad() {
716         if (hasDocErrorKrad()) {
717             String errorText = extractErrorTextKrad();
718             jiraAwareFail(errorText);
719         }
720     }
721 
722     protected String extractErrorText() {
723         String errorText = driver.findElement(By.xpath(DIV_ERROR_LOCATOR)).getText(); // don't highlight
724         errorText = blanketApprovalCleanUpErrorText(errorText);
725         if (driver.findElements(By.xpath(DIV_EXCOL_LOCATOR)).size() > 0) { // not present if errors are at the bottom of the page (see left-errmsg below)
726             errorText = blanketApprovalCleanUpErrorText(driver.findElement(
727                     // don't highlight
728                     By.xpath(DIV_EXCOL_LOCATOR)).getText()); // replacing errorText as DIV_EXCOL_LOCATOR includes the error count
729         }
730         if (driver.findElements(By.xpath(DIV_LEFT_ERRMSG)).size() > 0) {
731             errorText = errorText + blanketApprovalCleanUpErrorText(driver.findElement(
732                     By.xpath(DIV_LEFT_ERRMSG)).getText()); // don't highlight
733         }
734         return errorText;
735     }
736 
737     protected String extractErrorTextKrad() {
738         return driver.findElement(By.xpath(DIV_ERROR_LOCATOR_KRAD)).getText(); // don't highlight
739     }
740 
741     /**
742      * Uses Selenium's findElements method which does not throw a test exception if not found.
743      * @return
744      */
745     public boolean hasDocError() {
746         acceptAlertIfPresent(); // Agenda
747         if (driver.findElements(By.xpath(DIV_ERROR_LOCATOR)).size() > 0) {
748             String errorText = driver.findElement(By.xpath(DIV_ERROR_LOCATOR)).getText(); // don't highlight
749             if (errorText != null && errorText.contains("error(s) found on page.")) {
750                 return true;
751             }
752         }
753         return false;
754     }
755 
756     /**
757      * Uses Selenium's findElements method which does not throw a test exception if not found.
758      * @return
759      */
760     public boolean hasDocErrorKrad() {
761         if (driver.findElements(By.xpath(DIV_ERROR_LOCATOR_KRAD)).size() > 0) {
762             String errorText = driver.findElement(By.xpath(DIV_ERROR_LOCATOR_KRAD)).getText(); // don't highlight
763             if (errorText != null && !errorText.equals("")) {
764                 return true;
765             }
766         }
767         return false;
768     }
769 
770     /**
771      * Uses Selenium's findElements method which does not throw a test exception if not found.
772      * @param errorTextToMatch
773      * @return
774      */
775     public boolean hasDocError(String errorTextToMatch) {
776         if (driver.findElements(By.xpath(DIV_ERROR_LOCATOR)).size() > 0) {
777             String errorText = driver.findElement(By.xpath(DIV_ERROR_LOCATOR)).getText(); // don't highlight
778             if (errorText != null && errorText.contains("error(s) found on page.")) {
779                 WebElement errorDiv = driver.findElement(By.xpath("//div[@class='left-errmsg']/div[2]/div")); // don't highlight
780                 if (errorDiv != null) {
781                     errorText = errorDiv.getText();
782                     return errorText != null && errorText.contains(errorTextToMatch);
783                 }
784             }
785         }
786         return false;
787     }
788 
789     protected String configNameSpaceBlanketApprove() throws Exception {
790         String docId = waitForDocId();
791         String dtsPlusTwoChars = AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars();
792         waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Validation Test Namespace " + AutomatedFunctionalTestUtils
793                 .createUniqueDtsPlusTwoRandomCharsNot9Digits());
794         assertBlanketApproveButtonsPresent();
795         waitAndTypeByXpath(DOC_CODE_XPATH, "VTN" + dtsPlusTwoChars);
796         waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']",
797                 "Validation Test NameSpace " + dtsPlusTwoChars);
798         waitAndTypeByXpath("//input[@id='document.newMaintainableObject.applicationId']", "RICE");
799 
800         return docId;
801     }
802 
803     protected void contextLookupAssertions() throws Exception {
804         testLookUp();
805         assertTextPresent("Notes and Attachments");
806         jGrowl("Click Cancel");
807         waitAndClickByXpath("//button[@data-performDirtyValidation=\"true\"]"); // first cancel button is for attachment cancel and is hidden
808     }
809 
810     //    protected void deleteSubCollectionLine() throws Exception {
811     //        // click on collections page link
812     //        waitAndClickByLinkText(COLLECTIONS_LINK_TEXT);
813     //        Thread.sleep(5000);
814     //
815     //        // wait for collections page to load by checking the presence of a sub collection line item
816     //        waitForElementPresentByName("list4[0].subList[0].field1");
817     //
818     //        // change a value in the line to be deleted
819     //        waitAndTypeByName("list4[0].subList[0].field1", "selenium");
820     //
821     //        // click the delete button
822     //        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");
823     //        Thread.sleep(2000);
824     //
825     //        // confirm that the input box containing the modified value is not present
826     //        for (int second = 0;; second++) {
827     //            if (second >= waitSeconds)
828     //                jiraAwareFail(TIMEOUT_MESSAGE);
829     //            try {
830     //                if (!"selenium".equals(waitAndGetAttributeByName("list4[0].subList[0].field1", "value")))
831     //                    break;
832     //            } catch (Exception e) {}
833     //            Thread.sleep(1000);
834     //        }
835     //
836     //        // verify that the value has changed for the input box in the line that has replaced the deleted one
837     //        assertNotSame("selenium", waitAndGetAttributeByName("list4[0].subList[0].field1", "value"));
838     //    }
839 
840     protected void expandColapseByXpath(String clickLocator, String visibleLocator) throws InterruptedException {
841         waitAndClickByXpath(clickLocator);
842         waitIsVisibleByXpath(visibleLocator);
843         waitAndClickByXpath(clickLocator);
844         waitNotVisibleByXpath(visibleLocator);
845     }
846 
847     protected String getDocStatus() {
848         return findElement(By.xpath(DOC_STATUS_XPATH_2)).getText();
849     }
850 
851     /**
852      * <p>
853      * Handles simple nested frame content; validates that a frame and nested frame exists before
854      * switching to it.
855      * </p><p>
856      * Uses Selenium's findElements method which does not throw a test exception if not found.
857      * </p>
858      */
859     protected void gotoNestedFrame() {
860         driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS);
861         driver.switchTo().defaultContent();
862         final String iframeXpath = "//iframe";
863 
864         gotoIframeByXpath(iframeXpath);
865 
866         gotoIframeByXpath(iframeXpath);
867 
868         driver.manage().timeouts().implicitlyWait(waitSeconds, TimeUnit.SECONDS);
869     }
870 
871     @Override
872     protected void logout() throws InterruptedException {
873         selectTopFrame();
874         if (isElementPresentByXpath(LOGOUT_XPATH)) {
875             waitAndClickLogout(this);
876         }
877     }
878 
879     protected void lookupDocByWildcardedUniqueStringName() throws InterruptedException {
880         open(getBaseUrlString() + getBookmarkUrl());
881         selectFrameIframePortlet();
882         waitAndTypeByName("name", "*" + uniqueString);
883         waitAndClickSearch();
884     }
885 
886     protected boolean noAffilication() {
887         return !isElementPresentByName("document.affiliations[0].dflt");
888     }
889 
890     /**
891      * recalls a document.
892      * closes the page when done.
893      *
894      * @param cancel if true, performs recall and cancel. if false, performs recall to action list
895      *
896      * @throws InterruptedException
897      */
898     protected void recall(boolean cancel) throws InterruptedException {
899         waitAndClickByName("methodToCall.recall");
900         waitForTextPresent("the reason below");
901         waitAndTypeByName("reason", "Recall " + uniqueString);
902         if (cancel){
903             // recall and cancel
904             waitAndClickByName("methodToCall.processAnswer.button1");
905             waitForTextPresent("RECALLED");
906             waitAndClickByName("methodToCall.close");
907         } else {
908             // recall to action list
909             waitAndClickByName("methodToCall.processAnswer.button0");
910             waitForTextPresent("SAVED");
911             waitAndClickByName("methodToCall.close");
912             waitAndClickByName("methodToCall.processAnswer.button1");
913         }
914     }
915 
916     protected void saveSuccessfully() throws InterruptedException {
917         saveSuccessfully(WebDriverUtils.configuredImplicityWait() * 4);
918     }
919 
920     protected void saveSuccessfully(int secondsToWait) throws InterruptedException {
921         waitAndClickSaveByText();
922         waitForProgressSaving(secondsToWait);
923         checkForDocErrorKrad();
924         waitForTextPresent("Document was successfully saved.");
925     }
926 
927     protected void selectFrameIframePortlet() {
928         selectFrame(IFRAMEPORTLET_NAME);
929     }
930 
931     protected void selectFrame(String locator) {
932 
933         if (IFRAMEPORTLET_NAME.equals(locator)) {
934             gotoNestedFrame();
935         } else {
936             WebDriverUtils.selectFrameSafe(driver, locator);
937         }
938     }
939 
940     protected void submitSuccessfully() throws InterruptedException {
941         submitSuccessfully(WebDriverUtils.configuredImplicityWait() * 4);
942     }
943 
944     protected void submitSuccessfully(int loadingSeconds) throws InterruptedException {
945         waitAndClickSubmitByText();
946         waitAndClickConfirmSubmitOk();
947         waitForProgressLoading(loadingSeconds);
948         Thread.sleep(500);
949         checkForDocError();
950         checkForDocErrorKrad();
951         waitForTextPresent("Document was successfully submitted.");
952     }
953 
954     protected void testAddingBrownGroup() throws Exception {
955         selectFrameIframePortlet();
956         waitAndCreateNew();
957         String docId = waitForDocId();
958         String random = RandomStringUtils.randomNumeric(4);
959         String organizationDocumentNumber = "ORD" + random;
960         String groupDescription = "GD" + random;
961         String groupName = "BrownGroup " + AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars();
962         String nameSpace = "KR-IDM";
963         String today = getDateToday();
964         Calendar nextYearCal = Calendar.getInstance();
965         nextYearCal.add(Calendar.YEAR, 1);
966         SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
967         String nextYear = sdf.format(nextYearCal.getTime());
968 
969         //Enter details for BrownGroup.
970         waitAndTypeByName("document.documentHeader.documentDescription", "Adding Brown Group");
971         waitAndTypeByName("document.documentHeader.explanation", "I want to add Brown Group to test KIM");
972         waitAndTypeByName("document.documentHeader.organizationDocumentNumber", organizationDocumentNumber);
973         selectOptionByName("document.groupNamespace", nameSpace);
974         waitAndTypeByName("document.groupName", groupName);
975         waitAndTypeByName("document.groupDescription", groupDescription);
976         
977         checkByName("document.active");
978         waitAndClickByXpath(SAVE_XPATH_2);
979         waitForTextPresent("Document was successfully saved.");
980     }
981     
982     protected void testAddingBrownGroupSubmit() throws Exception {
983     	selectFrameIframePortlet();
984         waitAndCreateNew();
985         String docId = waitForDocId();
986         String random = RandomStringUtils.randomNumeric(4);
987         String organizationDocumentNumber = "ORD" + random;
988         String groupDescription = "GD" + random;
989         String groupName = "BrownGroup " + AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars();
990         String nameSpace = "KR-IDM";
991         String today = getDateToday();
992         acceptAlertIfPresent();
993         Calendar nextYearCal = Calendar.getInstance();
994         nextYearCal.add(Calendar.YEAR, 1);
995         SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
996         String nextYear = sdf.format(nextYearCal.getTime());
997 
998         //Enter details for BrownGroup.
999         waitAndTypeByName("document.documentHeader.documentDescription", "Adding Brown Group");
1000         waitAndTypeByName("document.documentHeader.explanation", "I want to add Brown Group to test KIM");
1001         waitAndTypeByName("document.documentHeader.organizationDocumentNumber", organizationDocumentNumber);
1002         selectOptionByName("document.groupNamespace", nameSpace);
1003         waitAndTypeByName("document.groupName", groupName);
1004         waitAndTypeByName("document.groupDescription", groupDescription);
1005 
1006         checkByName("document.active");
1007         waitAndClickByXpath(SUBMIT_XPATH);
1008     }
1009     
1010     protected void testAddingBrownGroupSaveSubmit() throws Exception {
1011     	selectFrameIframePortlet();
1012         waitAndCreateNew();
1013         String docId = waitForDocId();
1014         String random = RandomStringUtils.randomNumeric(4);
1015         String organizationDocumentNumber = "ORD" + random;
1016         String groupDescription = "GD" + random;
1017         String groupName = "BrownGroup " + AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars();
1018         String nameSpace = "KR-IDM";
1019         String today = getDateToday();
1020         Calendar nextYearCal = Calendar.getInstance();
1021         nextYearCal.add(Calendar.YEAR, 1);
1022         SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
1023         String nextYear = sdf.format(nextYearCal.getTime());
1024 
1025         //Enter details for BrownGroup.
1026         waitAndTypeByName("document.documentHeader.documentDescription", "Adding Brown Group");
1027         waitAndTypeByName("document.documentHeader.explanation", "I want to add Brown Group to test KIM");
1028         waitAndTypeByName("document.documentHeader.organizationDocumentNumber", organizationDocumentNumber);
1029         selectOptionByName("document.groupNamespace", nameSpace);
1030         waitAndTypeByName("document.groupName", groupName);
1031         waitAndTypeByName("document.groupDescription", groupDescription);
1032 
1033         waitAndClickByXpath(SAVE_XPATH_2);
1034         waitForTextPresent("Document was successfully saved.");
1035         waitAndClickByXpath(SUBMIT_XPATH);
1036         waitForTextPresent("Document was successfully submitted.");
1037     }
1038 
1039     protected void testAttributeDefinitionLookUp() throws Exception {
1040         waitForPageToLoad();
1041         selectFrameIframePortlet();
1042         waitAndClickByXpath("//button[contains(.,'earch')]");
1043         Thread.sleep(3000);
1044         waitForPageToLoad();
1045         findElement(By.tagName("body")).getText().contains("Actions"); // there are no actions, but the header is the only unique text from searching
1046         waitAndClickByLinkText("1000");
1047         waitForPageToLoad();
1048         findElement(By.tagName("body")).getText().contains("Attribute Inquiry");
1049         findElement(By.tagName("body")).getText().contains("KRMS Attributes");
1050         findElement(By.tagName("body")).getText().contains("Attribute Label");
1051         findElement(By.tagName("body")).getText().contains("1000");
1052         findElement(By.tagName("body")).getText().contains("peopleFlowId");
1053         findElement(By.tagName("body")).getText().contains("KR-RULE");
1054         findElement(By.tagName("body")).getText().contains("PeopleFlow");
1055 
1056         // selectFrame("name=fancybox-frame1343151577256"); // TODO parse source to get name
1057         // jiraAwareWaitAndClick("css=button:contains(Close)"); // looks lower case, but is upper
1058         // Thread.sleep(500);
1059         // jiraAwareWaitAndClick("css=button:contains(cancel)");
1060         // AttributeDefinition's don't have actions (yet)
1061         // jiraAwareWaitAndClick("id=u80");
1062         // waitForPageToLoad();
1063         // jiraAwareWaitAndClick("id=u86");
1064         // waitForPageToLoad();
1065         // selectWindow("null");
1066         // jiraAwareWaitAndClick("xpath=(//input[@name='imageField'])[2]");
1067         // waitForPageToLoad();
1068         passed();
1069     }
1070 
1071     protected String testBlanketApprove() throws Exception {
1072         selectFrameIframePortlet();
1073         waitAndCreateNew();
1074         String docId = verifyDocInitiated();
1075         assertBlanketApproveButtonsPresent();
1076         createNewLookupDetails();
1077 
1078         jGrowl("Click Blanket Approve");
1079         waitAndClickBlanketApproveKns();
1080 
1081         int attempts = 0;
1082         while (hasDocError() && extractErrorText().contains("a record with the same primary key already exists.") &&
1083                 ++attempts <= 3) {
1084             uniqueString = null; // make sure try a new one
1085             jGrowl("record with the same primary key already exists");
1086             createNewEnterDetails();
1087             jGrowl("Click Blanket Approve");
1088             waitAndClickBlanketApproveKns();
1089         }
1090 
1091         checkForIncidentReport();
1092         blanketApproveAssert(docId);
1093         return docId;
1094     }
1095 
1096     protected void waitAndClickBlanketApproveKns() throws InterruptedException {
1097         waitAndClickByName(BLANKET_APPROVE_NAME,
1098                 "No blanket approve button does the user " + getUserName() + " have permission?");
1099         waitForProgressLoading();
1100     }
1101 
1102     protected void testCancelConfirmation() throws InterruptedException {
1103         waitAndCancelConfirmation();
1104     }
1105 
1106     protected void testCreateDocType() throws Exception {
1107         selectFrameIframePortlet();
1108         waitAndCreateNew();
1109         assertElementPresentByXpath("//*[@name='methodToCall.route' and @alt='submit']","submit button does not exist on the page");
1110 
1111         //waitForElementPresentByXpath(DOC_ID_XPATH);
1112         //String docId = findElement(By.xpath(DOC_ID_XPATH)).getText();
1113         String docId = waitForDocId();
1114         waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Creating new Document Type");
1115         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,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;"
1116                 + getBaseUrlString() + "/kr/lookup.do;::::).anchor4']";
1117         waitAndClickByXpath(parentDocType);
1118         waitForPageToLoad();
1119         Thread.sleep(2000);
1120         waitAndClickSearch();
1121         waitAndClickReturnValue();
1122         String docTypeName = "TestDocType" + AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars();
1123         waitForElementPresentByXpath("//input[@id='document.newMaintainableObject.name']");
1124         waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", docTypeName);
1125         waitAndTypeByXpath("//input[@id='document.newMaintainableObject.unresolvedDocHandlerUrl']","${kr.url}/maintenance.do?methodToCall=docHandler");
1126 
1127         //waitAndTypeByXpath("//input[@id='document.newMaintainableObject.actualNotificationFromAddress']", "NFA");
1128         waitAndTypeByXpath("//input[@id='document.newMaintainableObject.label']", "Label for " + docTypeName);
1129         waitAndTypeByXpath("//input[@id='document.newMaintainableObject.unresolvedHelpDefinitionUrl']","default.htm?turl=WordDocuments%2Fdocumenttype.htm");
1130         jGrowl("Click Submit button");
1131         waitAndClickByXpath("//*[@name='methodToCall.route' and @alt='submit']");
1132         checkForIncidentReport();
1133         waitForPageToLoad();
1134         driver.switchTo().defaultContent();
1135         waitAndClickDocSearchTitle();
1136         waitForPageToLoad();
1137         selectFrameIframePortlet();
1138         waitAndTypeByName("documentId", docId);
1139         waitAndClickSearch();
1140         assertEquals(docId, waitForElementPresent(By.xpath(DOC_ID_XPATH_2)).getText());
1141     }
1142 
1143     protected String testCreateNew() throws InterruptedException {
1144         selectFrameIframePortlet();
1145         waitAndCreateNew();
1146         String docId = verifyDocInitiated();
1147         createNewEnterDetails();
1148         return docId;
1149     }
1150 
1151     protected String testCreateNewCancel() throws Exception {
1152         selectFrameIframePortlet();
1153         waitAndCreateNew();
1154         String docId = verifyDocInitiated();
1155         createNewEnterDetails();
1156         testCancelConfirmation();
1157         assertDocSearchNoResults(docId);
1158         return docId;
1159     }
1160 
1161     protected void testCreateNewRequired() throws Exception {
1162         selectFrameIframePortlet();
1163         waitAndCreateNew();
1164         waitAndClickSubmit();
1165         assertTrue(waitForElementVisibleBy(By.xpath("//div[@class='error']")).getText().contains(
1166                 " error(s) found on page."));
1167     }
1168     
1169     protected String testCreateNewSave() throws Exception {
1170         selectFrameIframePortlet();
1171         waitAndCreateNew();
1172         String docId = verifyDocInitiated();
1173         createNewEnterDetails();
1174         waitAndClickSave();
1175 
1176         int attempts = 0;
1177         while (hasDocError() && extractErrorText().contains("a record with the same primary key already exists.") &&
1178                 ++attempts <= 3) {
1179             uniqueString = null; // make sure try a new one
1180             jGrowl("record with the same primary key already exists");
1181             createNewEnterDetails();
1182             waitAndClickSave();
1183         }
1184 
1185         checkForDocError();
1186         waitForSuccessfulSaveMessage();
1187         assertDocSearch(docId, "SAVED");
1188         waitAndClickRouteLogIcon();
1189         assertRouteStatus("SAVED");
1190         back();
1191         return docId;
1192     }
1193 
1194     protected void waitForSuccessfulSaveMessage() throws InterruptedException {
1195         waitForElementVisibleBy(By.xpath(SAVE_SUCCESSFUL_XPATH));
1196     }
1197 
1198     protected String testCreateNewSubmit() throws Exception {
1199         selectFrameIframePortlet();
1200         waitAndCreateNew();
1201         String docId = verifyDocInitiated();
1202         createNewEnterDetails();
1203         waitAndClickSubmit();
1204         int attempts = 0;
1205         while (hasDocError() && extractErrorText().contains("a record with the same primary key already exists.") &&
1206                 ++attempts <= 3) {
1207             uniqueString = null; // make sure try a new one
1208             jGrowl("record with the same primary key already exists");
1209             createNewEnterDetails();
1210             waitAndClickSubmit();
1211         }
1212 
1213         checkForDocError();
1214         waitForSuccessfulSubmitMessage();
1215         assertDocSearch(docId, "FINAL");
1216         waitAndClickRouteLogIcon();
1217         assertRouteStatus("FINAL");
1218         back();
1219         return docId;
1220     }
1221 
1222     protected void waitForSuccessfulSubmitMessage()
1223             throws InterruptedException {waitForElementVisibleBy(By.xpath(DOC_SUBMIT_SUCCESS_MSG_XPATH));}
1224 
1225     protected String testCreateNewSaveSubmit() throws Exception {
1226         selectFrameIframePortlet();
1227         waitAndCreateNew();
1228         String docId = verifyDocInitiated();
1229         createNewEnterDetails();
1230         waitAndClickSave();
1231 
1232         int attempts = 0;
1233         while (hasDocError() && extractErrorText().contains("a record with the same primary key already exists.") &&
1234                 ++attempts <= 3) {
1235             uniqueString = null; // make sure try a new one
1236             jGrowl("record with the same primary key already exists");
1237             createNewEnterDetails();
1238             waitAndClickSave();
1239         }
1240 
1241         checkForDocError();
1242         waitForSuccessfulSaveMessage();
1243         waitAndClickSubmit();
1244         checkForDocError();
1245         waitForSuccessfulSubmitMessage();
1246         assertDocSearch(docId, "FINAL");
1247         waitAndClickRouteLogIcon();
1248         assertRouteStatus("FINAL");
1249         back();
1250         return docId;
1251     }
1252 
1253     protected String verifyDocInitiated() throws InterruptedException {
1254         String docId = waitForDocId();
1255         assertEquals("INITIATED", waitForDocStatus());
1256         assertEquals(getUserName(), waitForDocInitiator());
1257         return docId;
1258     }
1259 
1260     protected List<String> testCreateNewParameter(String docId, String parameterName) throws Exception {
1261         waitForPageToLoad();
1262         docId = waitForDocId();
1263         //Enter details for Parameter.
1264         waitAndTypeByName("document.documentHeader.documentDescription", "Adding Test Parameter");
1265         selectOptionByName("document.newMaintainableObject.namespaceCode", "KR-WKFLW");
1266         waitAndTypeByName("document.newMaintainableObject.componentCode", "ActionList");
1267         waitAndTypeByName("document.newMaintainableObject.applicationId", "KUALI");
1268         parameterName = "TestIndicator" + AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars();
1269         waitAndTypeByName("document.newMaintainableObject.name", parameterName);
1270         waitAndTypeByName("document.newMaintainableObject.value", "Y");
1271         waitAndTypeByName("document.newMaintainableObject.description", "for testing");
1272         selectOptionByName("document.newMaintainableObject.parameterTypeCode", "HELP");
1273         waitAndClickByXpath("//input[@name='document.newMaintainableObject.evaluationOperatorCode' and @value='A']");
1274         waitAndClickSave();
1275         waitAndClickSubmit();
1276         waitForElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH, "Document is not submitted successfully");
1277 
1278 
1279         assertDocSearch(docId, DOC_STATUS_FINAL);
1280         selectTopFrame();
1281         List<String> params = new ArrayList<String>();
1282         params.add(docId);
1283         params.add(parameterName);
1284 
1285         return params;
1286     }
1287 
1288     protected List<String> testCreateNewParameterType(String docId, String parameterType, String parameterCode)throws Exception {
1289         waitForPageToLoad();
1290         docId = waitForDocId();
1291 
1292         //Enter details for Parameter.
1293         waitAndTypeByName("document.documentHeader.documentDescription", "Adding Test Parameter Type");
1294         parameterCode = RandomStringUtils.randomAlphabetic(4).toLowerCase();
1295         waitAndTypeByName("document.newMaintainableObject.code", parameterCode);
1296         parameterType = "testing " + AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars();
1297         waitAndTypeByName("document.newMaintainableObject.name", parameterType);
1298         waitAndClickSave();
1299         waitAndClickSubmit();
1300         waitForElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH, "Document is not submitted successfully");
1301         assertDocSearch(docId, DOC_STATUS_FINAL);
1302         selectTopFrame();
1303         List<String> params = new ArrayList<String>();
1304         params.add(docId);
1305         params.add(parameterType);
1306         params.add(parameterCode);
1307 
1308         return params;
1309     }
1310 
1311     protected void testCreateNewSearchReturnValueCancelConfirmation() throws InterruptedException, Exception {
1312         selectFrameIframePortlet();
1313         waitAndCreateNew();
1314         waitAndClickSearch2();
1315         waitAndClickReturnValue();
1316         waitAndCancelConfirmation();
1317         passed();
1318     }
1319 
1320     protected List<String> testCopyParameter(String docId, String parameterName) throws Exception {
1321         selectFrameIframePortlet();
1322         waitAndClickCopy();
1323         waitForPageToLoad();
1324         docId = waitForDocId();
1325         waitAndTypeByName("document.documentHeader.documentDescription", "Copying Test Parameter");
1326         selectOptionByName("document.newMaintainableObject.namespaceCode", "KR-WKFLW");
1327         waitAndTypeByName("document.newMaintainableObject.componentCode", "ActionList");
1328         waitAndTypeByName("document.newMaintainableObject.applicationId", "KUALI");
1329         parameterName = "TestIndicator" + AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars();
1330         waitAndTypeByName("document.newMaintainableObject.name", parameterName);
1331         waitAndClickSave();
1332         waitAndClickSubmit();
1333         waitForElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH, "Document is not submitted successfully");
1334         assertDocSearch(docId, DOC_STATUS_FINAL);
1335         selectTopFrame();
1336         List<String> params = new ArrayList<String>();
1337         params.add(docId);
1338         params.add(parameterName);
1339 
1340         return params;
1341     }
1342 
1343     protected List<String> testCopyParameterType(String docId, String parameterType, String parameterCode) throws Exception {
1344         selectFrameIframePortlet();
1345         waitAndClickCopy();
1346         waitForPageToLoad();
1347         docId = waitForDocId();
1348         waitAndTypeByName("document.documentHeader.documentDescription", "Copying Test Parameter");
1349         parameterCode = RandomStringUtils.randomAlphabetic(4).toLowerCase();
1350         waitAndTypeByName("document.newMaintainableObject.code", parameterCode);
1351         clearTextByName("document.newMaintainableObject.name");
1352         parameterType = "testing " + AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars();
1353         waitAndTypeByName("document.newMaintainableObject.name", parameterType);
1354         waitAndClickSave();
1355         waitAndClickSubmit();
1356         waitForElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH, "Document is not submitted successfully");
1357         assertDocSearch(docId, DOC_STATUS_FINAL);
1358         selectTopFrame();
1359         List<String> params = new ArrayList<String>();
1360         params.add(docId);
1361         params.add(parameterType);
1362         params.add(parameterCode);
1363 
1364         return params;
1365     }
1366 
1367     protected void testDemoCustomRuleEventAndDocumentEventMethodInvocationAccountTypeChec() throws InterruptedException {
1368         String randomCode = org.apache.commons.lang3.RandomStringUtils.randomAlphabetic(9).toUpperCase();
1369         waitAndTypeByName("document.documentHeader.documentDescription","Travel Account Maintenance New Test Document " + randomCode);
1370         waitAndTypeByName("document.newMaintainableObject.dataObject.number",randomCode);
1371         waitAndTypeByName("document.newMaintainableObject.dataObject.name","Test Account Name " + randomCode);
1372         waitAndClickByXpath("//button[contains(text(),'Submit')]");
1373         assertTravelAccountTypeCodeRequired();
1374     }
1375 
1376     protected void assertTravelAccountTypeCodeRequired() throws InterruptedException {
1377         waitForTextPresent("Travel Account Type Code: Required");
1378         fireEvent("document.newMaintainableObject.dataObject.accountTypeCode", "focus");
1379         waitForElementVisibleBy(By.xpath("//div[@class='popover top in uif-tooltip-error-cs']"));
1380         fireEvent("document.newMaintainableObject.dataObject.accountTypeCode", "blur");
1381         waitAndTypeByName("document.newMaintainableObject.dataObject.number", "a"); // focus, blur just doesn't do it sometimes
1382         if(isVisibleByXpath("//div[@class='popover top in uif-tooltip-error-cs']")){
1383             JiraAwareFailureUtils.fail("Required popup still present", this);
1384         }
1385     }
1386 
1387     protected void testDocTypeLookup() throws Exception {
1388         selectFrameIframePortlet();
1389         waitAndClickByXpath("//input[@title='Search Parent Name']");
1390         waitAndClickByXpath(SAVE_XPATH_3);
1391         waitAndClickByXpath("//table[@id='row']/tbody/tr[contains(td[3],'RiceDocument')]/td[1]/a");
1392         waitAndClickByXpath(SAVE_XPATH_3);
1393         assertEquals("RiceDocument", getTextByXpath("//table[@id='row']/tbody/tr/td[4]/a"));
1394         waitAndClickByName("methodToCall.clearValues");
1395         waitAndTypeByName("name", "Kuali*D");
1396         waitAndClickByXpath(SAVE_XPATH_3);
1397         assertElementPresentByXpath("//table[@id='row']/tbody/tr[contains(td[3], 'KualiDocument')]");
1398         String docIdOld = getTextByXpath("//table[@id='row']/tbody/tr[contains(td[3], 'KualiDocument')]/td[2]/a");
1399         waitAndClickByName("methodToCall.clearValues");
1400         waitAndTypeByName("label", "KualiDocument");
1401         waitAndClickByXpath(SAVE_XPATH_3);
1402         assertElementPresentByXpath("//table[@id='row']/tbody/tr[contains(td[5], 'KualiDocument')]");
1403         waitAndClickByName("methodToCall.clearValues");
1404         waitAndTypeByName("documentTypeId", docIdOld);
1405         waitAndClickByXpath(SAVE_XPATH_3);
1406         assertElementPresentByXpath("//table[@id='row']/tbody/tr[contains(td[2], '" + docIdOld + "')]");
1407     }
1408 
1409     protected void testEditCopy(String docId) throws InterruptedException {
1410         String desc = getDescriptionUnique();
1411         jiraAwareTypeByName("document.documentHeader.documentDescription", desc);
1412         String thisDocId = verifyDocInitiated();
1413         assertFalse("Document id should not be the same as original (" + docId + ").", docId.equals(thisDocId));
1414         waitAndClickSave();
1415         waitForSuccessfulSaveMessage();
1416         assertDocSearch(docId, "FINAL");
1417         waitAndClickRouteLogIcon();
1418         assertRouteStatus("FINAL");
1419         waitForElementPresentByXpath("//th[contains(.,'Title')]/../following-sibling::*/td[contains(.,'" + desc + "')]");
1420     }
1421 
1422     protected List<String> testEditParameterType(String docId, String parameterType, String parameterCode) throws Exception {
1423         selectFrameIframePortlet();
1424         waitAndClickEdit();
1425         waitForPageToLoad();
1426         docId = waitForDocId();
1427         waitAndTypeByName("document.documentHeader.documentDescription", "Editing Test Parameter");
1428         clearTextByName("document.newMaintainableObject.name");
1429         parameterType = "testing " + AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars();
1430         waitAndTypeByName("document.newMaintainableObject.name", parameterType);
1431         waitAndClickSave();
1432         waitAndClickSubmit();
1433         waitForElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH, "Document is not submitted successfully");
1434         assertDocSearch(docId, DOC_STATUS_FINAL);
1435         selectTopFrame();
1436         List<String> params = new ArrayList<String>();
1437         params.add(docId);
1438         params.add(parameterType);
1439         params.add(parameterCode);
1440 
1441         return params;
1442     }
1443 
1444     protected List<String> testEditParameter(String docId, String parameterName) throws Exception {
1445         selectFrameIframePortlet();
1446         waitAndClickEdit();
1447         waitForPageToLoad();
1448         docId = waitForDocId();
1449         waitAndTypeByName("document.documentHeader.documentDescription", "Editing Test Parameter");
1450         clearTextByName("document.newMaintainableObject.value");
1451         waitAndTypeByName("document.newMaintainableObject.value", "N");
1452         waitAndClickSave();
1453         waitAndClickSubmit();
1454         waitForElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH, "Document is not submitted successfully");
1455         assertDocSearch(docId, DOC_STATUS_FINAL);
1456         selectTopFrame();
1457         List<String> params = new ArrayList<String>();
1458         params.add(docId);
1459         params.add(parameterName);
1460         return params;
1461     }
1462 
1463     protected void testEditRouteRulesDelegation() throws Exception {
1464         waitForPageToLoad();
1465         Thread.sleep(3000);
1466         assertEquals("Kuali Portal Index", getTitle());
1467         selectFrameIframePortlet();
1468         waitAndClickSearch();
1469         waitAndClickEdit();
1470         waitForPageToLoad();
1471         Thread.sleep(3000);
1472         assertTrue(isElementPresentByName(CANCEL_NAME));
1473         waitAndClickCancel();
1474         waitAndClickByName("methodToCall.processAnswer.button0");
1475         waitForPageToLoad();
1476         passed();
1477     }
1478 
1479     protected void testFiscalOfficerInfoMaintenanceNew() throws Exception {
1480         selectFrameIframePortlet();
1481         checkForIncidentReport();
1482         String docId = getTextByXpath("//*[@id='u13_control']");
1483         waitAndTypeByXpath("//input[@name='document.documentHeader.documentDescription']", "New FO Doc");
1484         waitAndTypeByXpath("//input[@name='document.newMaintainableObject.dataObject.id']", "5");
1485         waitAndTypeByXpath("//input[@name='document.newMaintainableObject.dataObject.userName']", "Jigar");
1486         waitAndClickByXpath("//button[@id='usave']");
1487         Integer docIdInt = Integer.valueOf(docId).intValue();
1488         waitAndClickActionList();
1489         selectFrameIframePortlet();
1490 
1491         if(isElementPresentByLinkText("Last")){
1492             waitAndClickByLinkText("Last");
1493             waitAndClickByLinkText(docIdInt.toString());
1494         } else {
1495             waitAndClickByLinkText(docIdInt.toString());
1496         }
1497 
1498         //      ------------------------------- Not working in code when click docId link in list--------------------------
1499         //Thread.sleep(5000);
1500         //String[] windowTitles = getAllWindowTitles();
1501         //selectWindow(windowTitles[1]);
1502         //windowFocus();
1503         //assertEquals(windowTitles[1], getTitle());
1504         //checkForIncidentReport("Action List Id link opened window.", "https://jira.kuali.org/browse/KULRICE-9062 Action list id links result in 404 or NPE");
1505 
1506         //------submit-----//
1507         //selectFrame("relative=up");
1508         //waitAndClick("//button[@value='submit']");
1509         //waitForPageToLoad50000();
1510         //close();
1511         //------submit over---//
1512 
1513         //----step 2----//
1514         //selectWindow("null");
1515         //windowFocus();
1516         //waitAndClick("//img[@alt='doc search']");
1517         //waitForPageToLoad50000();
1518         //assertEquals(windowTitles[0], getTitle());
1519         //selectFrame("iframeportlet");
1520         //waitAndClick(SEARCH_XPATH);
1521         //waitForPageToLoad50000();
1522         //----step 2 over ----//
1523 
1524         //-----Step 3 verifies that doc is final-------//
1525         //assertEquals("FINAL", getText("//table[@id='row']/tbody/tr[1]/td[4]"));
1526         //selectFrame("relative=up");
1527         //waitAndClick("link=Main Menu");
1528         //waitForPageToLoad50000();
1529         //assertEquals(windowTitles[0], getTitle());
1530         //-----Step 3 verified that doc is final -------
1531     }
1532 
1533     protected void testIdentityPersonBlanketApprove() throws Exception {
1534         selectFrameIframePortlet();
1535         waitAndCreateNew();
1536         String docId = waitForDocId();
1537         waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Validation Test Person");
1538         assertBlanketApproveButtonsPresent();
1539         waitAndTypeByXpath("//input[@id='document.principalName']", "principal" + RandomStringUtils.randomAlphabetic(3).toLowerCase());
1540         selectByName("newAffln.affiliationTypeCode", "Affiliate");
1541         selectByName("newAffln.campusCode", "BX - BLGTN OFF CAMPUS");
1542         selectByName("newAffln.campusCode", "BL - BLOOMINGTON");
1543         assertElementPresentByName("newAffln.dflt");
1544         waitAndClickByName("newAffln.dflt");
1545         waitAndClickByName("methodToCall.addAffln.anchor");
1546         waitAndClickByName("methodToCall.toggleTab.tabContact");
1547         selectByName("newName.namePrefix", "Mr");
1548         waitAndTypeByName("newName.firstName", "First");
1549         waitAndTypeByName("newName.lastName", "Last");
1550         selectByName("newName.nameSuffix", "Mr");
1551         waitAndClickByName("newName.dflt");
1552         waitAndClickByName("methodToCall.addName.anchor");
1553         waitForPageToLoad();
1554         blanketApproveTest(docId);
1555     }
1556 
1557     protected  void testIdentityRoleSaveAndReload()throws Exception{
1558         selectFrameIframePortlet();
1559         waitAndClickSearch2();
1560         waitAndClickByXpath("//a[@title='edit Role withRole=63 ']");
1561         waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Test Save and Reload Role ");
1562         assertBlanketApproveButtonsPresent();
1563         waitAndClickByXpath(SAVE_XPATH_2);
1564         waitForTextPresent("Document was successfully saved.");
1565         waitAndClickByXpath(RELOAD_XPATH);
1566         waitForTextPresent("Document was successfully reloaded.");
1567         findElement(By.xpath("//div[@class='tab-container']")).getText().contains("Members:");
1568         passed();
1569     }
1570 
1571     protected void testIdentityRoleBlanketApprove() throws Exception {
1572         selectFrameIframePortlet();
1573         waitAndCreateNew();
1574         waitAndClickByXpath(SEARCH_XPATH, "No search button to click.");
1575         waitAndClickReturnValue();
1576         String docId = waitForDocId();
1577         String dtsTwo = AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomCharsNot9Digits();
1578         waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Validation Test Role " + dtsTwo);
1579         assertBlanketApproveButtonsPresent();
1580         selectByXpath("//select[@id='document.roleNamespace']", LABEL_KUALI_KUALI_SYSTEMS);
1581         waitAndTypeByXpath("//input[@id='document.roleName']", "Validation Test Role " + dtsTwo,
1582                 "No Role Name input to type in.");
1583         waitAndClickByName(
1584                 "methodToCall.performLookup.(!!org.kuali.rice.kim.impl.identity.PersonImpl!!).(((principalId:member.memberId,principalName:member.memberName))).((``)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;;::::).anchorAssignees");
1585         waitAndClickByXpath(SEARCH_XPATH, "No search button to click.");
1586         waitAndClickReturnValue();
1587         waitAndClickByName("methodToCall.addMember.anchorAssignees");
1588         waitForPageToLoad();
1589         blanketApproveTest(docId);
1590     }
1591 
1592     protected void finishBlanketApprovalTest(String docId) throws InterruptedException {
1593         assertBlanketApproveButtonsPresent();
1594         blanketApproveCheck();
1595         if (!hasDocError("same primary key already exists")) { // don't fail as to still have the same key after 25 sequential attempts we've created many today already
1596             blanketApproveAssert(docId);
1597         }
1598     }
1599 
1600     protected void testLookUp() throws Exception {
1601         waitForPageToLoad();
1602         selectFrameIframePortlet();
1603 
1604         // Mixed capitalization
1605         waitAndClick(By.xpath(SEARCH_XPATH_3));
1606         waitAndClickByLinkText(EDIT_LINK_TEXT, "edit button not present does user " + user + " have permission?");
1607         waitForTextPresent("ubmit");
1608         assertTextPresent("ave");
1609         assertTextPresent("pprove");
1610         assertTextPresent("lose");
1611         assertTextPresent("ancel");
1612     }
1613 
1614     protected void testReferenceCampusTypeBlanketApprove() throws Exception {
1615         selectFrameIframePortlet();
1616         String randomCode = searchForAvailableCode(1);
1617 
1618         waitAndCreateNew();
1619         String docId = waitForDocId();
1620         String dtsTwo = AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomCharsNot9Digits();
1621         waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Validation Test Campus Type " + randomCode + " " + dtsTwo);
1622         waitAndTypeByXpath(DOC_CODE_XPATH, randomCode);
1623         waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", "Indianapolis"  + randomCode + dtsTwo);
1624 
1625         finishBlanketApprovalTest(docId);
1626     }
1627 
1628     protected void performParameterInquiry(String parameterField) throws Exception {
1629         waitAndTypeByName("name", parameterField);
1630         waitAndClickSearch();
1631         isElementPresentByLinkText(parameterField);
1632         waitAndClickByLinkText(parameterField);
1633         waitForPageToLoad();
1634         Thread.sleep(2000);
1635         switchToWindow("Kuali :: Inquiry");
1636         Thread.sleep(2000);
1637     }
1638 
1639     protected List<String> testLookUpParameterType(String docId, String parameterType, String parameterCode) throws Exception {
1640         performParameterInquiry(parameterType);
1641         assertEquals(parameterCode, getTextByXpath("//div[@class='tab-container']/table//span[@id='code.div']").trim().toLowerCase());
1642         assertEquals(parameterType, getTextByXpath("//div[@class='tab-container']/table//span[@id='name.div']").trim().toLowerCase());
1643         waitAndClickCloseWindow();
1644         switchToWindow("null");
1645         List<String> params = new ArrayList<String>();
1646         params.add(docId);
1647         params.add(parameterType);
1648         params.add(parameterCode);
1649 
1650         return params;
1651     }
1652 
1653     protected List<String> testLookUpParameter(String docId, String parameterName) throws Exception {
1654         performParameterInquiry(parameterName);
1655         assertEquals(parameterName, getTextByXpath(
1656                 "//div[@class='tab-container']/table//span[@id='name.div']").trim());
1657         assertEquals("Y", getTextByXpath("//div[@class='tab-container']/table//span[@id='value.div']")
1658                 .trim());
1659         waitAndClickCloseWindow();
1660         switchToWindow("null");
1661         List<String> params = new ArrayList<String>();
1662         params.add(docId);
1663         params.add(parameterName);
1664 
1665         return params;
1666     }
1667 
1668     protected void testTermLookupAssertions() throws Exception {
1669         testLookUp();
1670         assertTextPresent("Term Parameters");
1671         waitAndClick(By.xpath(CANCEL2_XPATH));
1672         passed();
1673     }
1674 
1675     protected void testTermSpecificationLookupAssertions() throws Exception {
1676         testLookUp();
1677         assertTextPresent("Context");
1678         waitAndClickCancelByText();
1679         passed();
1680     }
1681 
1682     protected List<String> testVerifyModifiedParameter(String docId, String parameterName) throws Exception {
1683         performParameterInquiry(parameterName);
1684         assertEquals(parameterName, getTextByXpath("//div[@class='tab-container']/table//span[@id='name.div']").trim());
1685         assertEquals("N", getTextByXpath("//div[@class='tab-container']/table//span[@id='value.div']").trim());
1686         waitAndClickCloseWindow();
1687         switchToWindow("null");
1688         List<String> params = new ArrayList<String>();
1689         params.add(docId);
1690         params.add(parameterName);
1691 
1692         return params;
1693     }
1694 
1695     protected List<String> testVerifyCopyParameterType(String docId, String parameterType, String parameterCode) throws Exception
1696     {
1697         performParameterInquiry(parameterType);
1698         assertEquals(parameterType, getTextByXpath("//div[@class='tab-container']/table//span[@id='name.div']").trim().toLowerCase());
1699         waitAndClickCloseWindow();
1700         switchToWindow("null");
1701         List<String> params = new ArrayList<String>();
1702         params.add(docId);
1703         params.add(parameterType);
1704         params.add(parameterCode);
1705 
1706         return params;
1707     }
1708 
1709     protected List<String> testCreateNewPermission(String docId, String permissionName) throws Exception {
1710         waitForPageToLoad();
1711         Thread.sleep(2000);
1712         docId = waitForDocId();
1713         waitAndClickSave();
1714         waitForElementPresentByXpath("//div[contains(.,'Document Description (Description) is a required field.')]/img[@alt='error']");
1715         waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Adding Permission removeme");
1716         waitAndClickSubmit();
1717         waitForElementPresentByXpath("//div[@class='error']");
1718         assertElementPresentByXpath("//div[contains(.,'Template (Template) is a required field.')]/img[@alt='error']");
1719         assertElementPresentByXpath("//div[contains(.,'Permission Namespace (Permission Namespace) is a required field.')]/img[@alt='error']");
1720         assertElementPresentByXpath("//div[contains(.,'Permission Name (Permission Name) is a required field.')]/img[@alt='error']");
1721         selectOptionByName("document.newMaintainableObject.templateId", "36");
1722         selectOptionByName("document.newMaintainableObject.namespaceCode", "KR-SYS");
1723         permissionName = "removeme" + AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars();
1724         waitAndTypeByName("document.newMaintainableObject.name", permissionName);
1725         waitAndTypeByName("document.newMaintainableObject.description", "namespaceCode=KR*");
1726         checkByName("document.newMaintainableObject.active");
1727         waitAndClickSave();
1728         waitForElementPresentByXpath(SAVE_SUCCESSFUL_XPATH);
1729         assertEquals(DOC_STATUS_SAVED, getTextByXpath(DOC_STATUS_XPATH));
1730         waitAndClickSubmit();
1731         waitForElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH, "Document is not submitted successfully");
1732         assertEquals(DOC_STATUS_ENROUTE, getTextByXpath(DOC_STATUS_XPATH));
1733         List<String> params = new ArrayList<String>();
1734         params.add(docId);
1735         params.add(permissionName);
1736 
1737         return params;
1738     }
1739 
1740     protected List<String> testLookUpPermission(String docId, String permissionName) throws Exception {
1741         waitAndTypeByName("name", permissionName);
1742         waitAndClickSearch();
1743         isElementPresentByLinkText(permissionName);
1744         List<String> params = new ArrayList<String>();
1745         params.add(docId);
1746         params.add(permissionName);
1747 
1748         return params;
1749     }
1750 
1751     protected List<String> testEditPermission(String docId, String permissionName) throws Exception {
1752         waitAndClickEdit();
1753         waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Editing Permission removeme");
1754         uncheckByName("document.newMaintainableObject.active");
1755         waitAndClickSubmit();
1756         waitForElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH, "Document is not submitted successfully");
1757         List<String> params = new ArrayList<String>();
1758         params.add(docId);
1759         params.add(permissionName);
1760 
1761         return params;
1762     }
1763 
1764     protected List<String> testVerifyPermission(String docId, String permissionName) throws Exception {
1765         waitAndTypeByName("name", permissionName);
1766         waitAndClickByXpath("//input[@title='Active Indicator - No']");
1767         waitAndClickSearch();
1768         isElementPresentByLinkText(permissionName);
1769         List<String> params = new ArrayList<String>();
1770         params.add(docId);
1771         params.add(permissionName);
1772 
1773         return params;
1774     }
1775 
1776     protected List<String> testCreateNewPerson(String docId, String personName) throws Exception  {
1777         waitForPageToLoad();
1778         docId = waitForDocId();
1779         waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Adding Charlie Brown");
1780         waitAndTypeByName("document.documentHeader.explanation", "I want to add Charlie Brown to test KIM");
1781 
1782         //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.
1783         personName = "cbrown" + AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars();
1784         waitAndTypeByName("document.principalName", personName);
1785         waitAndClickSave();
1786         waitForElementPresentByXpath(SAVE_SUCCESSFUL_XPATH);
1787         assertEquals(DOC_STATUS_SAVED, getTextByXpath(DOC_STATUS_XPATH));
1788         waitAndClickSubmit();
1789         waitForElementPresentByXpath("//div[contains(.,'At least one affiliation must be entered.')]/img[@alt='error']");
1790         assertElementPresentByXpath("//div[contains(.,'At least one name must be entered.')]/img[@alt='error']");
1791         selectOptionByName("newAffln.affiliationTypeCode", "STDNT");
1792         selectOptionByName("newAffln.campusCode", "BL");
1793         checkByName("newAffln.dflt");
1794         waitAndClickByName("methodToCall.addAffln.anchor");
1795         waitAndSelectByName("newName.nameCode", "PRM");
1796         selectOptionByName("newName.namePrefix", "Mr");
1797         waitAndTypeByName("newName.firstName", "Charlie");
1798         waitAndTypeByName("newName.lastName", "Brown");
1799         checkByName("newName.dflt");
1800         waitAndClickByName("methodToCall.addName.anchor");
1801         waitAndClickSubmit();
1802         waitForElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH, "Document is not submitted successfully");
1803         assertEquals(DOC_STATUS_ENROUTE, getTextByXpath(DOC_STATUS_XPATH));
1804         List<String> params = new ArrayList<String>();
1805         params.add(docId);
1806         params.add(personName);
1807 
1808         return params;
1809     }
1810 
1811     protected List<String> testLookUpPerson(String docId, String personName) throws Exception {
1812         waitAndTypeByName("principalName", personName);
1813         waitAndClickSearch();
1814         isElementPresentByLinkText(personName);
1815         waitAndClickByName("methodToCall.clearValues");
1816         waitAndTypeByName("firstName", "Charlie");
1817         waitAndClickSearch();
1818         isElementPresentByLinkText(personName);
1819         waitAndClickByName("methodToCall.clearValues");
1820         waitAndTypeByName("lastName", "Brown");
1821         waitAndClickSearch();
1822         isElementPresentByLinkText(personName);
1823         waitAndClickByName("methodToCall.clearValues");
1824         waitAndTypeByName("campusCode", "BL");
1825         waitAndClickSearch();
1826         isElementPresentByLinkText(personName);
1827         List<String> params = new ArrayList<String>();
1828         params.add(docId);
1829         params.add(personName);
1830 
1831         return params;
1832     }
1833 
1834     protected List<String> testVerifyPerson(String docId, String personName) throws Exception {
1835         waitAndClickByLinkText(personName);
1836         waitForPageToLoad();
1837         Thread.sleep(5000);
1838         switchToWindow("Kuali :: Person");
1839         Thread.sleep(2000);
1840         assertEquals(personName, getTextByXpath("//div[@class='tab-container']/table//tr[2]/td[1]/div").trim());
1841         assertEquals("BL - BLOOMINGTON", getTextByXpath("//div[@class='tab-container']/table[3]//tr[2]/td[2]/div").trim());
1842         assertEquals("Student", getTextByXpath("//select/option[@selected]").trim());
1843         assertElementPresentByXpath("//table[@class='tab']//input[@title='close Overview']");
1844         assertElementPresentByXpath("//table[@class='tab']//input[@title='open Contact']");
1845         assertElementPresentByXpath("//table[@class='tab']//input[@title='open Privacy Preferences']");
1846         assertElementPresentByXpath("//table[@class='tab']//input[@title='open Membership']");
1847         waitAndClickByName("methodToCall.showAllTabs");
1848         waitForElementPresentByXpath("//table[@class='tab']//input[@title='close Overview']");
1849         assertElementPresentByXpath("//table[@class='tab']//input[@title='close Contact']");
1850         assertElementPresentByXpath("//table[@class='tab']//input[@title='close Privacy Preferences']");
1851         assertElementPresentByXpath("//table[@class='tab']//input[@title='close Membership']");
1852         waitAndClickByName("methodToCall.hideAllTabs");
1853         waitForElementPresentByXpath("//table[@class='tab']//input[@title='open Overview']");
1854         assertElementPresentByXpath("//table[@class='tab']//input[@title='open Contact']");
1855         assertElementPresentByXpath("//table[@class='tab']//input[@title='open Privacy Preferences']");
1856         assertElementPresentByXpath("//table[@class='tab']//input[@title='open Membership']");
1857         waitAndClickCloseWindow();
1858         switchToWindow("null");
1859         List<String> params = new ArrayList<String>();
1860         params.add(docId);
1861         params.add(personName);
1862 
1863         return params;
1864     }
1865 
1866     protected void testConfigurationTestView(String idPrefix) throws Exception {
1867         waitForElementPresentByXpath("//label[@id='" + idPrefix + "TextInputField_label']");
1868 
1869         // testing for https://groups.google.com/a/kuali.org/group/rice.usergroup.krad/browse_thread/thread/1e501d07c1141aad#
1870         String styleValue = waitAndGetAttributeByXpath("//label[@id='" + idPrefix + "TextInputField_label']",
1871                 "style");
1872 
1873         // log.info("styleValue is " + styleValue);
1874         assertTrue(idPrefix + "textInputField label does not contain expected style", styleValue.replace(" ", "").contains("color:red"));
1875 
1876         // get current list of options
1877         String refreshTextSelectLocator = "//select[@id='" + idPrefix + "RefreshTextField_control']";
1878         String[] options1 = getSelectOptionsByXpath(refreshTextSelectLocator);
1879         String dropDownSelectLocator = "//select[@id='" + idPrefix + "DropDown_control']";
1880         selectByXpath(dropDownSelectLocator, "Vegetables");
1881         Thread.sleep(3000);
1882 
1883         //get list of options after change
1884         String[] options2 = getSelectOptionsByXpath(refreshTextSelectLocator);
1885 
1886         //verify that the change has occurred
1887         assertFalse("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",
1888                 options1[options1.length - 1].equalsIgnoreCase(options2[options2.length - 1]));
1889 
1890         //confirm that control gets disabled
1891         selectByXpath(dropDownSelectLocator, "None");
1892         Thread.sleep(3000);
1893         assertEquals("true", waitAndGetAttributeByXpath(refreshTextSelectLocator, "disabled"));
1894     }
1895 
1896     //    protected void testTravelAccountTypeLookup() throws Exception {
1897     //        selectFrameIframePortlet();
1898     //
1899     //        //Blank Search
1900     //        waitAndClickByXpath("//*[contains(button,\"earch\")]/button[1]");
1901     //        Thread.sleep(4000);
1902     //        assertElementPresentByXpath("//table[@class='uif-tableCollectionLayout dataTable']//tr[contains(td[1],'CAT')]");
1903     //        assertElementPresentByXpath("//table[@class='uif-tableCollectionLayout dataTable']//tr[contains(td[1],'EAT')]");
1904     //        assertElementPresentByXpath("//table[@class='uif-tableCollectionLayout dataTable']//tr[contains(td[1],'IAT')]");
1905     //
1906     //        //search with each field
1907     //        waitAndTypeByName("lookupCriteria[accountTypeCode]", "CAT");
1908     //        waitAndClickByXpath("//*[contains(button,\"earch\")]/button[1]");
1909     //        Thread.sleep(2000);
1910     //        assertElementPresentByXpath("//table[@class='uif-tableCollectionLayout dataTable']//tr[contains(td[1],'CAT')]");
1911     //        waitAndClickByXpath("//*[contains(button,\"earch\")]/button[2]");
1912     //        Thread.sleep(2000);
1913     //        waitAndTypeByName("lookupCriteria[name]", "Expense Account Type");
1914     //        waitAndClickByXpath("//*[contains(button,\"earch\")]/button[1]");
1915     //        Thread.sleep(4000);
1916     //        assertElementPresentByXpath("//table[@class='uif-tableCollectionLayout dataTable']//tr[contains(td[1],'EAT')]");
1917     //
1918     //        //Currently No links available for Travel Account Type Inquiry so cant verify heading and values.
1919     //    }
1920 
1921     protected void testCategoryLookUp() throws Exception {
1922         waitForPageToLoad();
1923         selectFrameIframePortlet();
1924         waitAndClickByXpath("//button[contains(.,'earch')]");
1925         Thread.sleep(3000);
1926         waitForPageToLoad();
1927         findElement(By.tagName("body")).getText().contains("Actions"); // there are no actions, but the header is the only unique text from searching
1928 
1929         // Category's don't have actions (yet)
1930         //waitAndClick("id=u80");
1931         //waitForPageToLoad();
1932         //waitAndClick("id=u86");
1933         //waitForPageToLoad();
1934         //selectWindow("null");
1935         //waitAndClick("xpath=(//input[@name='imageField'])[2]");
1936         //waitForPageToLoad();
1937         //passed();
1938     }
1939 
1940     protected void testCreateSampleEDocLite() throws Exception {
1941         waitForPageToLoad();
1942         Thread.sleep(3000);
1943         assertEquals("Kuali Portal Index", getTitle());
1944         selectFrameIframePortlet();
1945         waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
1946         waitForPageToLoad();
1947 
1948         // click on the create new.
1949         waitAndClickByLinkText("Create Document");
1950         waitForPageToLoad();
1951         Thread.sleep(3000);
1952         String docId = getTextByXpath("//table/tbody/tr[4]/td[@class='datacell1']");
1953         waitAndTypeByName("userName", "Viral Chauhan");
1954         waitAndTypeByName("rqstDate", "12/03/2020");
1955         checkByName("fundedBy");
1956         waitAndTypeByName("addText", "Note Added.");
1957         waitAndClickByXpath("//td[@class='datacell']/div/img");
1958         waitAndClickByXpath("//input[@value='submit']");
1959         assertEquals(Boolean.FALSE, (Boolean) isElementPresentByXpath("//input[@value='submit']"));
1960         assertEquals(Boolean.FALSE, (Boolean) isElementPresentByXpath("//input[@value='save']"));
1961         assertEquals(Boolean.FALSE, (Boolean) isElementPresentByXpath("//input[@value='cancel']"));
1962         waitForPageToLoad();
1963         selectTopFrame();
1964         waitAndClickDocSearch();
1965         waitForPageToLoad();
1966         selectFrameIframePortlet();
1967         waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
1968         waitForElementPresent(By.linkText(docId));
1969     }
1970 
1971     protected void testTermLookUp() throws Exception {
1972         testLookUp();
1973         assertTextPresent("Term Parameters");
1974         waitAndClickCancelByText();
1975         passed();
1976     }
1977 
1978     protected void testCreateNewRRDTravelRequestDestRouting() throws Exception {
1979         selectFrameIframePortlet();
1980 
1981         // Create new Routing Rules Delegation
1982         waitAndClick("img[alt=\"create new\"]");
1983 
1984         // Lookup parent rule, click lookup icon
1985         waitAndClickByName(
1986                 "methodToCall.performLookup.(!!org.kuali.rice.kew.rule.RuleBaseValues!!).(((id:parentRuleId))).((``)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;;::::).anchor");
1987 
1988         // Search
1989         waitAndClickByXpath("//td[@class='infoline']/input[@name='methodToCall.search']");
1990 
1991         // return value for 1046 TravelRequest.Destination.LasVegas TravelRequest-DestinationRouting
1992         waitAndClick("a[title=\"return valueRule Id=1046 \"]");
1993 
1994         // Select the parent rule we just returned
1995         waitAndClickByName("parentResponsibilityId");
1996 
1997         // Click continue
1998         waitAndClickByName("methodToCall.createDelegateRule");
1999 
2000         waitAndClickCancel();
2001         waitAndClickByName("methodToCall.processAnswer.button0");
2002         waitForPageToLoad();
2003         driver.switchTo().defaultContent();
2004         waitAndClickByXpath("(//input[@name='imageField'])[2]");
2005         passed();
2006     }
2007 
2008     protected void testWorkFlowRouteRulesCreateNew() throws Exception {
2009         waitForPageToLoad();
2010         Thread.sleep(5000);
2011         assertEquals("Kuali Portal Index", getTitle());
2012         selectFrameIframePortlet();
2013         waitAndClickCreateNew();
2014         waitAndClickByName(CANCEL_NAME, "https://jira.kuali.org/browse/KULRICE-8161 Work Flow Route Rules cancel new yields 404 not found");
2015 
2016         // KULRICE-7753 : WorkFlowRouteRulesIT cancel confirmation missing from create new Route Rules.
2017         waitAndClickByName("methodToCall.processAnswer.button0");
2018         passed();
2019     }
2020 
2021     /**
2022      * tests that a Routing Rule maintenance document is created for an edit operation originating
2023      * from a lookup screen
2024      */
2025     protected void testWorkFlowRouteRulesEditRouteRules() throws Exception {
2026         waitForPageToLoad();
2027         assertEquals("Kuali Portal Index", getTitle());
2028         selectFrameIframePortlet();
2029         waitAndClickSearch();
2030         waitAndClickEdit();
2031         waitForPageToLoad();
2032         selectFrameIframePortlet();
2033         waitAndClickCancel();
2034         waitAndClickByName("methodToCall.processAnswer.button0");
2035         passed();
2036     }
2037 
2038     /**
2039      * Look at the Location*Aft classes for the current best practices on implementing this method
2040      * @throws InterruptedException
2041      */
2042     protected void createNewEnterDetails() throws InterruptedException {
2043         // overload to utilize
2044         fail("createNewEnterDetails must be implemented by test class");
2045     }
2046 
2047     /**
2048      * Look at the Location*Aft classes for the current best practices on implementing this method
2049      * @throws InterruptedException
2050      */
2051     protected void createNewLookupDetails() throws InterruptedException {
2052         // overload to utilize
2053         fail("createNewLookupDetails must be implemented by test class");
2054     }
2055 
2056 //    protected String createNewTemplateMethod() throws InterruptedException {
2057 //        waitAndCreateNew();
2058 //        String docId = waitForDocId();
2059 //
2060 //        createNewEnterDetails();
2061 //
2062 //        // Ad Hoc Recipients with current user to test Action List
2063 //        addAdHocRecipientsPerson(new String[]{getUserName(), "F"}); // FYI
2064 //
2065 //        waitAndClickSave();
2066 //        waitAndClickSubmit();
2067 //        waitForElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH, CREATE_NEW_DOCUMENT_NOT_SUBMITTED_SUCCESSFULLY_MESSAGE_TEXT);
2068 //
2069 //        // Action List
2070 //        assertActionList(docId, "F", "ENROUTE"); // FYI
2071 //
2072 //        assertDocSearch(docId, DOC_STATUS_FINAL);
2073 //        selectTopFrame();
2074 //        return docId;
2075 //    }
2076 //
2077 //    protected String createNewTemplateMethodNoAction() throws InterruptedException {
2078 //        waitAndCreateNew();
2079 //        String docId = waitForDocId();
2080 //
2081 //        createNewEnterDetails();
2082 //
2083 //        waitAndClickSave();
2084 //        waitAndClickSubmit();
2085 //        waitForElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH, CREATE_NEW_DOCUMENT_NOT_SUBMITTED_SUCCESSFULLY_MESSAGE_TEXT);
2086 //
2087 //        assertDocSearch(docId, DOC_STATUS_FINAL);
2088 //        selectTopFrame();
2089 //        return docId;
2090 //    }
2091 
2092     protected void waitAndClickActionList() throws InterruptedException {
2093         WebDriverUtils.jGrowl(driver, "Click Action List", false, "Click Action List");
2094         selectTopFrame();
2095         waitAndClickByXpath("//img[@alt='action list']");
2096     }
2097 
2098     protected void testLookUpComponent(String docId, String componentName, String componentCode) throws Exception {
2099         selectFrameIframePortlet();
2100         //Lookup
2101         waitAndTypeByName("name", componentName);
2102         waitAndClickSearch();
2103         isElementPresentByLinkText(componentName);
2104         waitAndClickByLinkText(componentName);
2105         waitForPageToLoad();
2106         Thread.sleep(2000);
2107         switchToWindow("Kuali :: Inquiry");
2108         Thread.sleep(2000);
2109         assertEquals(componentName, getTextByXpath("//div[@class='tab-container']/table//span[@id='name.div']").trim());
2110         assertEquals(componentCode, getTextByXpath("//div[@class='tab-container']/table//span[@id='code.div']").trim());
2111         waitAndClickCloseWindow();
2112         switchToWindow("null");
2113     }
2114 
2115     protected void testEditComponent(String docId, String componentName, String componentCode) throws Exception {
2116         selectFrameIframePortlet();
2117         waitAndClickEdit();
2118         waitForPageToLoad();
2119         docId = waitForDocId();
2120         waitAndTypeByName("document.documentHeader.documentDescription", "Editing Test Component");
2121         clearTextByName("document.newMaintainableObject.name");
2122         waitAndTypeByName("document.newMaintainableObject.name", componentName);
2123         waitAndClickSave();
2124         waitAndClickSubmit();
2125         waitForElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH, "Document is not submitted successfully");
2126         assertDocSearch(docId, DOC_STATUS_FINAL);
2127         selectTopFrame();
2128     }
2129 
2130     protected void testCopyComponent(String docId, String componentName, String componentCode) throws Exception {
2131         selectFrameIframePortlet();
2132         waitAndClickCopy();
2133         waitForPageToLoad();
2134         docId = waitForDocId();
2135         waitAndTypeByName("document.documentHeader.documentDescription", "Copying Test Component");
2136         selectOptionByName("document.newMaintainableObject.namespaceCode", "KR-IDM");
2137         waitAndTypeByName("document.newMaintainableObject.code", componentCode);
2138         clearTextByName("document.newMaintainableObject.name");
2139         waitAndTypeByName("document.newMaintainableObject.name", componentName);
2140         waitAndClickSave();
2141         waitAndClickSubmit();
2142         waitForPageToLoad();
2143         checkForDocError();
2144         waitForElementPresentByXpath(DOC_SUBMIT_SUCCESS_MSG_XPATH, "Document is not submitted successfully");
2145         assertDocSearch(docId, DOC_STATUS_FINAL);
2146         selectTopFrame();
2147     }
2148 
2149     protected void testVerifyCopyComponent(String docId, String componentName, String componentCode) throws Exception {
2150         selectFrameIframePortlet();
2151         waitAndTypeByName("name", componentName);
2152         waitAndClickSearch();
2153         isElementPresentByLinkText(componentName);
2154         waitAndClickByLinkText(componentName);
2155         waitForPageToLoad();
2156         Thread.sleep(2000);
2157         switchToWindow("Kuali :: Inquiry");
2158         Thread.sleep(2000);
2159         assertEquals(componentName, getTextByXpath("//div[@class='tab-container']/table//span[@id='name.div']").trim());
2160         assertEquals(componentCode, getTextByXpath("//div[@class='tab-container']/table//span[@id='code.div']").trim());
2161         waitAndClickCloseWindow();
2162         switchToWindow("null");
2163     }
2164 
2165     protected void testMultiValueSelectAllPages() throws InterruptedException {
2166         waitAndClickButtonByText(SEARCH);
2167         assertButtonDisabledByText(RETURN_SELECTED_BUTTON_TEXT);
2168 
2169         // select all, all checkboxes should be checked and return button enabled
2170         waitAndClickDropDown("select all items");
2171         if (!areAllMultiValueSelectsChecked()) {
2172             JiraAwareFailureUtils.fail("select all items failure", this);
2173         }
2174         assertButtonEnabledByText(RETURN_SELECTED_BUTTON_TEXT);
2175 
2176         boolean anotherPageOfResults = false;
2177         if (Integer.parseInt(multiValueResultCount()) > 10) {
2178             anotherPageOfResults = true;
2179         }
2180 
2181         // all should be checked and button enabled on the next page as well (server side paging)
2182         if (!anotherPageOfResults) {
2183             JiraAwareFailureUtils.fail("select all items server side paging failure not enough results for next page",
2184                     this);
2185         }
2186         waitAndClickByLinkText("Next");
2187 
2188         if (!areAllMultiValueSelectsChecked()) {
2189             JiraAwareFailureUtils.fail("select all items server side paging failure", this);
2190         }
2191         assertButtonEnabledByText(RETURN_SELECTED_BUTTON_TEXT);
2192 
2193         // deselect all no checkboxes should be checked and return button disabled
2194         waitAndClickDropDown("deselect all items");
2195         if (!areNoMultiValueSelectsChecked()) {
2196             JiraAwareFailureUtils.fail("deselect all items failure", this);
2197         }
2198         assertButtonDisabledByText(RETURN_SELECTED_BUTTON_TEXT);
2199 
2200         waitAndClickByLinkText("Previous");
2201         if (!areNoMultiValueSelectsChecked()) {
2202             JiraAwareFailureUtils.fail("deselect all items failure", this);
2203         }
2204         assertButtonDisabledByText(RETURN_SELECTED_BUTTON_TEXT);
2205     }
2206 
2207     protected void acceptAlert() {
2208         if (!WebDriverUtils.isAlertPresent(driver)) {
2209             fail("Alert expected but not present for " + this.getClass().getName());
2210         }
2211         WebDriverUtils.alertAccept(driver);
2212     }
2213 
2214     protected void testMultiValueSelectAllThisPage() throws InterruptedException {
2215         waitAndClickButtonByText(SEARCH);
2216         assertButtonDisabledByText(RETURN_SELECTED_BUTTON_TEXT);
2217 
2218         // select all on this page, all checkboxes should be checked and return button enabled
2219         assertMultiValueSelectAllThisPage();
2220 
2221         boolean anotherPageOfResults = false;
2222         if (Integer.parseInt(multiValueResultCount()) > 5) {
2223             anotherPageOfResults = true;
2224         }
2225 
2226         // the next page should not have any checkboxes checked return button should still be enabled
2227         waitAndClickByLinkText("Next");
2228         if (!areNoMultiValueSelectsChecked()) {
2229             if (anotherPageOfResults) {
2230                 JiraAwareFailureUtils.fail("select all items on this page failure", this);
2231             } else {
2232                 JiraAwareFailureUtils.fail("select all items on this page failure not enough results for next page",
2233                         this);
2234             }
2235         }
2236         assertButtonEnabledByText(RETURN_SELECTED_BUTTON_TEXT);
2237 
2238         // back to the previous page, checkboxes should be checked and return button enabled still
2239         waitAndClickByLinkText("Previous");
2240         if (!areAllMultiValueSelectsChecked()) {
2241             JiraAwareFailureUtils.fail("select all items on previous page failure", this);
2242         }
2243 
2244         // deselect no checkboxes should be checked and the return button should be disabled
2245         assertMultiValueDeselectAllThisPage();
2246     }
2247 
2248     /**
2249      * Test the external help on the section and fields
2250      */
2251     protected void testExternalHelp2() throws Exception {
2252         // test external help of section
2253         assertPopUpWindowUrl(By.cssSelector("input[title=\"Help for External Help\"]"), "HelpWindow",
2254                 "http://www.kuali.org/?section");
2255 
2256         // test external help of field with label left
2257         assertPopUpWindowUrl(By.xpath("//div[@id='field-label-left-external-help']/fieldset/input[@title='Help for Field Label']"), "HelpWindow",
2258                 "http://www.kuali.org/?label_left");
2259 
2260         // test external help of field with label right
2261         assertPopUpWindowUrl(By.xpath("//div[@id='field-label-right-external-help']/fieldset/input[@title='Help for Field Label']"), "HelpWindow",
2262                 "http://www.kuali.org/?label_right");
2263 
2264         // test external help of field with label top and help URL from system parameters
2265         assertPopUpWindowUrl(By.xpath("//div[@id='field-label-top-external-help']/fieldset/input[@title='Help for Field Label']"), "HelpWindow",
2266                 "http://www.kuali.org/?system_parm");
2267 
2268         // test external help of standalone help widget
2269         assertPopUpWindowUrl(By.id("standalone-external-help"), "HelpWindow", "http://www.kuali.org/?widget_only");
2270     }
2271 
2272     /**
2273      * Test the external help on the sub-section and display only fields
2274      */
2275 
2276     protected void testDisplayOnlyExternalHelp2() throws Exception {
2277         // test external help of sub-section
2278         assertPopUpWindowUrl(By.cssSelector("input[title=\"Help for Display only fields\"]"), "HelpWindow", "http://www.kuali.org/?sub_section");
2279 
2280         // test external help of display only data field
2281         assertPopUpWindowUrl(By.xpath(
2282                 "//div[@id='display-field-external-help']/fieldset/input[@title='Help for Field Label']"), "HelpWindow",
2283                 "http://www.kuali.org/?display_field");
2284     }
2285 
2286     /**
2287      * Test the external help on the section and fields with missing help URL
2288      */
2289 
2290     protected void testMissingExternalHelp2() throws Exception {
2291         // test external help of section is not rendered
2292         assertFalse(isElementPresent(By.cssSelector("input[title=\"Help for Missing External Help\"]")));
2293 
2294         // test external help of field with blank externalHelpURL is not rendered
2295         assertFalse(isElementPresentByXpath("//div[@id='external-help-externalHelpUrl-empty']/*[@class='uif-helpImage']"));
2296 
2297         // test external help of field with empty helpDefinition is not rendered
2298         assertFalse(isElementPresentByXpath("//div[@id='external-help-helpdefinition-empty']/*[@class='uif-helpImage']"));
2299 
2300         // test external help of field with missing system parameter is not rendered
2301         assertFalse(isElementPresentByXpath("//div[@id='external-help-system-parm-missing']/*[@class='uif-helpImage']"));
2302 
2303         // test external help of standalone help widget is not rendered
2304         assertFalse(isElementPresentByXpath("//div[@id='standalone-external-help-missing']"));
2305     }
2306 
2307     private String searchForAvailableCode(int codeLength) throws InterruptedException {
2308         String randomCode = RandomStringUtils.randomAlphabetic(codeLength).toUpperCase();
2309         waitAndTypeByName("code", randomCode);
2310         waitAndClickSearch();
2311         int attemptCount = 1;
2312         waitForTextPresent("You have entered the primary key for this table");
2313         while (!isTextPresent("No values match this search.") && attemptCount < 25) {
2314             randomCode = Character.toString((char) (randomCode.toCharArray()[0] + attemptCount++));
2315             clearTextByName("code");
2316             waitAndTypeByName("code", randomCode);
2317             waitAndClickSearch();
2318             waitForTextPresent("You have entered the primary key for this table");
2319         }
2320         return randomCode;
2321     }
2322 
2323     protected void testSearchEditCancel() throws InterruptedException {
2324         selectFrameIframePortlet();
2325         waitAndClickSearch2();
2326         waitAndClickEdit();
2327         testCancelConfirmation();
2328     }
2329 
2330     protected void testServerErrorsIT() throws Exception {
2331         waitAndClickByXpath("//button[contains(.,'Get Error Messages')]");
2332         waitForElementPresent("div[data-messages_for=\"Demo-ValidationLayout-SectionsPage\"] .uif-errorMessageItem-field");
2333         waitIsVisibleByXpath("//header[@data-header_for='Demo-ValidationLayout-Section1']");
2334         assertElementPresentByXpath("//*[@data-messageitemfor='Demo-ValidationLayout-Section1' and @class='uif-errorMessageItem']");
2335         assertElementPresent("div[data-role=\"InputField\"] img[alt=\"Error\"]");
2336         assertElementPresentByXpath("//a[contains(.,'Section 1 Title')]");
2337         fireMouseOverEventByXpath("//a[contains(.,'Field 1')]");
2338         assertElementPresent(".uif-errorMessageItem-field");
2339         waitAndClickByXpath("//a[contains(.,'Field 1')]");
2340         waitIsVisible(".popover");
2341         waitIsVisible(".popover-content > .uif-serverMessageItems");
2342         waitIsVisible(".popover-content > .uif-serverMessageItems .uif-errorMessageItem-field");
2343         waitAndTypeByName("field1", "");
2344         fireEvent("field1", "blur");
2345         fireEvent("field1", "focus");
2346         waitIsVisible(".popover");
2347         waitIsVisible(".popover-content > .uif-serverMessageItems .uif-errorMessageItem-field");
2348         waitIsVisible(".popover-content > .uif-clientMessageItems");
2349         waitIsVisible(".popover-content > .uif-clientMessageItems  .uif-errorMessageItem-field");
2350         waitAndTypeByName("field1", "t");
2351 
2352         for (int second = 0;; second++) {
2353             if (second >= waitSeconds) {
2354                 jiraAwareFail(TIMEOUT_MESSAGE);
2355             }
2356             try {
2357                 if (!isElementPresent(".popover-content > .uif-clientMessageItems")) {
2358                     break;
2359                 }
2360             } catch (Exception e) {}
2361             Thread.sleep(1000);
2362         }
2363 
2364         waitIsVisible(".popover-content > .uif-serverMessageItems .uif-errorMessageItem-field");
2365         assertFalse(isElementPresent(".popover-content > .uif-clientMessageItems"));
2366     }
2367 
2368     protected void testServerInfoIT() throws Exception {
2369         waitAndClickByXpath("//button[contains(.,'Get Info Messages')]");
2370         waitIsVisibleByXpath("//div[@data-messages_for='Demo-ValidationLayout-SectionsPage']");
2371         waitForProgressLoading();
2372         assertTrue(isVisibleByXpath("//div[@data-messages_for='Demo-ValidationLayout-SectionsPage']"));
2373         assertTrue(isElementPresent(
2374                 "div[data-messages_for=\"Demo-ValidationLayout-SectionsPage\"] .uif-infoMessageItem"));
2375         assertTrue(isVisible("div[data-messages_for=\"Demo-ValidationLayout-Section1\"]"));
2376         assertTrue(isElementPresent("div[data-messages_for=\"Demo-ValidationLayout-Section1\"] .uif-infoMessageItem"));
2377         assertTrue(isElementPresentByXpath("//div[@data-role='InputField']//img[@alt='Information']"));
2378         fireMouseOverEventByXpath("//a[contains(.,'Field 1')]");
2379         assertTrue(isElementPresent(".uif-infoHighlight"));
2380         waitAndClickByXpath("//a[contains(.,'Field 1')]");
2381         waitForElementPresentByXpath("//div[@class='popover top in uif-tooltip-info-ss']");
2382         waitAndTypeByName("field1", "");
2383         fireEvent("field1", "blur");
2384         fireEvent("field1", "focus");
2385         waitForElementPresentByXpath("//div[@class='popover uif-tooltip-info-ss top in uif-tooltip-error-ss']");
2386         waitAndTypeByName("field1", "b");
2387         fireEvent("field1", "blur");
2388         fireEvent("field1", "focus");
2389         waitForElementPresentByXpath("//div[@class='popover uif-tooltip-error-ss top in uif-tooltip-info-ss']");
2390         fireEvent("field1", "focus");
2391         clearTextByName("field1");
2392         fireEvent("field1", "blur");
2393         waitForElementPresentByXpath("//div[@class='popover uif-tooltip-info-ss top in uif-tooltip-error-ss']");
2394     }
2395 
2396     protected void testServerWarningsIT() throws Exception {
2397         waitAndClickByXpath("//button[contains(.,'Get Warning Messages')]");
2398         waitForElementPresentByXpath("//div[@id='Demo-ValidationLayout-SectionsPage_messages']");
2399         waitForElementPresentByXpath("//div[@id='Demo-ValidationLayout-Section1_messages']");
2400         waitForElementPresentByXpath("//a[contains(.,'Field 1')]");
2401         fireMouseOverEventByXpath("//a[contains(.,'Field 1')]");
2402         waitForElementPresentByXpath(
2403                 "//div[@class='uif-inputField uif-boxLayoutHorizontalItem uif-hasWarning uif-warningHighlight']");
2404         waitAndClickByXpath("//a[contains(.,'Field 1')]");
2405         waitForElementPresentByXpath("//div[@class='popover uif-tooltip-warning-ss top in uif-tooltip-error-ss']");
2406         waitAndTypeByName("field1", "");
2407         fireEvent("field1", "blur");
2408         fireMouseOverEventByName("field1");
2409         waitForElementPresentByXpath("//div[@class='popover uif-tooltip-warning-ss top in uif-tooltip-error-ss']");
2410         waitAndTypeByName("field1", "b");
2411         fireEvent("field1", "blur");
2412         fireMouseOverEventByName("field1");
2413         waitForElementPresentByXpath("//div[@class='popover uif-tooltip-warning-ss top in uif-tooltip-error-ss']");
2414         clearTextByName("field1");
2415         fireEvent("field1", "blur");
2416         fireMouseOverEventByName("field1");
2417         waitForElementPresentByXpath("//div[@class='popover uif-tooltip-warning-ss top in uif-tooltip-error-ss']");
2418         passed();
2419     }
2420 
2421     /**
2422      * Test the tooltip and external help on the view
2423      */
2424     protected void testViewHelp2() throws Exception {
2425         // test tooltip help
2426         if (isElementPresentByXpath("//td[@class='jquerybubblepopup-innerHtml']")) {
2427             assertFalse(findElement(By.cssSelector("td.jquerybubblepopup-innerHtml")).isDisplayed());
2428         }
2429 
2430         // test tooltip help
2431         fireMouseOverEventByXpath("//h1/span[@class='uif-headerText-span']");
2432         Thread.sleep(2000);
2433         assertTrue(isVisibleByXpath("//td[contains(text(),'View help')]"));
2434         assertPopUpWindowUrl(By.cssSelector("input[title=\"Help for Configuration Test View\"]"), "HelpWindow", "http://www.kuali.org/");
2435     }
2436 
2437     protected void testVerifyAddDeleteFiscalOfficerLegacy() throws Exception {
2438         selectFrameIframePortlet();
2439         waitAndTypeByName("document.documentHeader.documentDescription", AutomatedFunctionalTestUtils
2440                 .createUniqueDtsPlusTwoRandomChars());
2441         waitAndTypeByName("newCollectionLines['document.newMaintainableObject.dataObject.fiscalOfficer.accounts'].number","1234567890");
2442         waitAndTypeByName("newCollectionLines['document.newMaintainableObject.dataObject.fiscalOfficer.accounts'].foId", "2");
2443         waitAndClickByXpath("//button[@data-loadingmessage='Adding Line...']");
2444         waitForElementPresentByName("document.newMaintainableObject.dataObject.fiscalOfficer.accounts[0].number");
2445         assertEquals("1234567890", waitAndGetAttributeByName(
2446                 "document.newMaintainableObject.dataObject.fiscalOfficer.accounts[0].number", "value"));
2447         assertEquals("2", waitAndGetAttributeByName(
2448                 "document.newMaintainableObject.dataObject.fiscalOfficer.accounts[0].foId", "value"));
2449         waitAndClickByXpath("//button[@data-loadingmessage='Deleting Line...']");
2450         Thread.sleep(3000);
2451         assertEquals(Boolean.FALSE, (Boolean) isElementPresentByName(
2452                 "document.newMaintainableObject.dataObject.fiscalOfficer.accounts[0].number"));
2453         passed();
2454     }
2455 
2456     protected void testVerifyAddDeleteNoteLegacy() throws Exception {
2457         selectFrameIframePortlet();
2458         waitAndClick(
2459                 "div.tableborders.wrap.uif-boxLayoutVerticalItem.clearfix  span.uif-headerText-span > img.uif-disclosure-image");
2460         waitForElementPresent("button[title='Add a Note'].uif-action.uif-primaryActionButton.uif-smallActionButton");
2461         waitAndClickByName("newCollectionLines['document.notes'].noteText");
2462         waitAndTypeByName("newCollectionLines['document.notes'].noteText", "Test note");
2463         waitAndClick("button[title='Add a Note'].uif-action.uif-primaryActionButton.uif-smallActionButton");
2464         //        waitForElementPresentByName("document.notes[0].noteText");
2465         assertEquals("Test note", getTextByXpath("//pre"));
2466         waitAndClick("button[title='Delete a Note'].uif-action.uif-primaryActionButton.uif-smallActionButton");
2467         assertEquals(Boolean.FALSE, (Boolean) isElementPresentByName("document.notes[0].noteText"));
2468         passed();
2469     }
2470 
2471     protected void testVerifyAdHocRecipientsLegacy() throws Exception {
2472         selectFrameIframePortlet();
2473         waitAndClickByLinkText("Fiscal Officer Accounts");
2474         assertElementPresentByXpath(
2475                 "//select[@name=\"newCollectionLines['document.adHocRoutePersons'].actionRequested\"]");
2476         assertElementPresentByXpath(
2477                 "//input[@name=\"newCollectionLines['document.adHocRoutePersons'].name\" and @type=\"text\"]");
2478         assertElementPresentByXpath(
2479                 "//select[@name=\"newCollectionLines['document.adHocRouteWorkgroups'].actionRequested\"]");
2480         assertElementPresentByXpath(
2481                 "//input[@name=\"newCollectionLines['document.adHocRouteWorkgroups'].recipientNamespaceCode\" and @type='text']");
2482         assertElementPresentByXpath(
2483                 "//input[@name=\"newCollectionLines['document.adHocRouteWorkgroups'].recipientName\" and @type='text']");
2484         passed();
2485     }
2486 
2487     protected void testVerifyButtonsLegacy() throws Exception {
2488         selectFrameIframePortlet();
2489         assertElementPresentByXpath("//button[contains(.,'ubmit')]");
2490         assertElementPresentByXpath("//button[contains(.,'ave')]");
2491         assertElementPresentByXpath("//button[contains(.,'lanket approve')]");
2492         assertElementPresentByXpath("//button[contains(.,'lose')]");
2493         assertElementPresentByXpath("//a[contains(.,'ancel')]");
2494         passed();
2495     }
2496 
2497     protected void testVerifyConstraintText() throws Exception {
2498         selectFrameIframePortlet();
2499         assertEquals("* indicates required field", getText(
2500                 "div.uif-boxLayout.uif-horizontalBoxLayout.clearfix > span.uif-message.uif-requiredInstructionsMessage.uif-boxLayoutHorizontalItem"));
2501         assertEquals("Must not be more than 10 characters", getText(
2502                 "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"));
2503         assertEquals("Must not be more than 10 characters", getText(
2504                 "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"));
2505         assertEquals("Must not be more than 10 characters", getText(
2506                 "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"));
2507         passed();
2508     }
2509 
2510     protected void testVerifyEditedComponent(String docId, String componentName, String componentCode) throws Exception {
2511         selectFrameIframePortlet();
2512         waitAndTypeByName("name", componentName);
2513         waitAndClickSearch();
2514         isElementPresentByLinkText(componentName);
2515         waitAndClickByLinkText(componentName);
2516         waitForPageToLoad();
2517         Thread.sleep(2000);
2518         switchToWindow("Kuali :: Inquiry");
2519         Thread.sleep(2000);
2520         assertEquals(componentName, getTextByXpath("//div[@class='tab-container']/table//span[@id='name.div']").trim());
2521         assertEquals(componentCode, getTextByXpath("//div[@class='tab-container']/table//span[@id='code.div']").trim());
2522         waitAndClickCloseWindow();
2523         switchToWindow("null");
2524         List<String> parameterList=new ArrayList<String>();
2525     }
2526 
2527     protected void testVerifyDisclosures() throws Exception {
2528         selectFrameIframePortlet();
2529         assertElementPresentByXpath("//span[contains(text(),'Document Overview')]");
2530         assertElementPresentByXpath("//span[contains(text(),'Document Overview')]");
2531         assertElementPresentByXpath("//span[contains(text(),'Account Information')]");
2532         assertElementPresentByXpath("//span[contains(text(),'Fiscal Officer Accounts')]");
2533         assertElementPresentByXpath("//span[contains(text(),'Notes and Attachments')]");
2534         assertElementPresentByXpath("//span[contains(text(),'Ad Hoc Recipients')]");
2535         assertElementPresentByXpath("//span[contains(text(),'Route Log')]");
2536         colapseExpandByXpath("//span[contains(text(),'Document Overview')]//img",
2537                 "//label[contains(text(),'Organization Document Number')]");
2538         colapseExpandByXpath("//span[contains(text(),'Account Information')]//img",
2539                 "//label[contains(text(),'Travel Account Type Code')]");
2540         colapseExpandByXpath("//span[contains(text(),'Fiscal Officer Accounts')]//img",
2541                 "//a[contains(text(),'Lookup/Add Multiple Lines')]");
2542         expandColapseByXpath("//span[contains(text(),'Notes and Attachments')]//img",
2543                 "//label[contains(text(),'Note Text')]");
2544         expandColapseByXpath("//span[contains(text(),'Ad Hoc Recipients')]",
2545                 "//span[contains(text(),'Ad Hoc Group Requests')]");
2546 
2547         // Handle frames
2548         waitAndClickByXpath("//span[contains(text(),'Route Log')]//img");
2549         selectFrame("routeLogIFrame");
2550         waitIsVisibleByXpath("//img[@alt='refresh']");
2551 
2552         // relative=top iframeportlet might look weird but either alone results in something not found.
2553         selectTopFrame();
2554         selectFrameIframePortlet();
2555         waitAndClickByXpath("//span[contains(text(),'Route Log')]//img");
2556         selectFrame("routeLogIFrame");
2557         waitNotVisibleByXpath("//img[@alt='refresh']");
2558         passed();
2559     }
2560 
2561     protected void testVerifyDocumentOverviewLegacy() throws Exception {
2562         selectFrameIframePortlet();
2563         assertTextPresent("Document Overview");
2564         assertElementPresentByXpath("//input[@name='document.documentHeader.documentDescription']");
2565         assertElementPresentByXpath("//input[@name='document.documentHeader.organizationDocumentNumber']");
2566         assertElementPresentByXpath("//textarea[@name='document.documentHeader.explanation']");
2567         passed();
2568     }
2569 
2570     protected void testVerifyExpandCollapse() throws Exception {
2571         selectFrameIframePortlet();
2572         assertElementPresentByXpath("//button[contains(@class, 'uif-expandDisclosuresButton')]");
2573         assertElementPresentByXpath("//button[contains(@class, 'uif-collapseDisclosuresButton')]");
2574         passed();
2575     }
2576 
2577     protected void testVerifyFieldsLegacy() throws Exception {
2578         selectFrameIframePortlet();
2579         assertElementPresentByXpath("//input[@name='document.newMaintainableObject.dataObject.number' and @type='text' and @size=10 and @maxlength=10]");
2580         assertElementPresentByXpath("//input[@name='document.newMaintainableObject.dataObject.extension.accountTypeCode' and @type='text' and @size=2 and @maxlength=3]");
2581         assertElementPresentByXpath(
2582                 "//input[@name='document.newMaintainableObject.dataObject.subAccount' and @type='text' and @size=10 and @maxlength=10]");
2583         assertElementPresentByXpath("//input[@name='document.newMaintainableObject.dataObject.subsidizedPercent' and @type='text' and @size=6 and @maxlength=20]");
2584         assertElementPresentByXpath(
2585                 "//input[@name='document.newMaintainableObject.dataObject.foId' and @type='text' and @size=5 and @maxlength=10]");
2586         assertElementPresentByXpath(
2587                 "//input[@name=\"newCollectionLines['document.newMaintainableObject.dataObject.fiscalOfficer.accounts'].number\" and @type='text' and @size=10 and @maxlength=10]");
2588         assertElementPresentByXpath(
2589                 "//input[@name=\"newCollectionLines['document.newMaintainableObject.dataObject.fiscalOfficer.accounts'].foId\" and @type='text' and @size=5 and @maxlength=10]");
2590         passed();
2591     }
2592 
2593     protected void testVerifyHeaderFieldsLegacy() throws Exception {
2594         selectFrameIframePortlet();
2595         assertElementPresentByXpath("//div[contains(@class, 'uif-documentNumber')]");
2596         assertElementPresentByXpath("//div[contains(@class, 'uif-documentInitiatorNetworkId')]");
2597         assertElementPresentByXpath("//div[contains(@class, 'uif-documentStatus')]");
2598         assertElementPresentByXpath("//div[contains(@class, 'uif-documentCreateDate')]");
2599         passed();
2600     }
2601 
2602     protected void testVerifyLookupAddMultipleLinesLegacy() throws Exception {
2603         selectFrameIframePortlet();
2604         assertElementPresentByXpath("//a[contains(text(),'Lookup/Add Multiple Lines')]");
2605         passed();
2606     }
2607 
2608     protected void testVerifyNotesAndAttachments() throws Exception {
2609         selectFrameIframePortlet();
2610         waitAndClickByXpath("//span[contains(text(),'Notes and Attachments')]");
2611         waitForElementPresentByXpath("//button[@title='Add a Note']");
2612         assertElementPresentByXpath("//span[contains(text(),'Notes and Attachments')]");
2613         assertElementPresentByXpath("//textarea[@name=\"newCollectionLines['document.notes'].noteText\"]");
2614         assertElementPresentByXpath("//input[@name='attachmentFile']");
2615 
2616         //assertElementPresentByXpath("//input[@name=\"newCollectionLines['document.notes'].attachment.attachmentTypeCode\"]");
2617         passed();
2618     }
2619 
2620     protected void testVerifyQuickfinderIconsLegacy() throws Exception {
2621         selectFrameIframePortlet();
2622         assertTextPresent("Document Overview");
2623         assertElementPresentByXpath("//*[@id='quickfinder1']");
2624         assertElementPresentByXpath("//*[@id='quickfinder2']");
2625         assertElementPresentByXpath("//*[@id='quickfinder3']");
2626         assertElementPresentByXpath("//*[@id='quickfinder4_add']");
2627 
2628         // TODO it would be better to test that the image isn't 404
2629         passed();
2630     }
2631 
2632     protected void testVerifyRouteLog() throws Exception {
2633         selectFrameIframePortlet();
2634         waitAndClickByLinkText("Route Log");
2635         waitForElementPresent("//iframe[contains(@src,'RouteLog.do')]");
2636         passed();
2637     }
2638 
2639     protected void testVerifySave() throws Exception {
2640         selectFrameIframePortlet();
2641         waitAndTypeByName("document.documentHeader.documentDescription",
2642                 "Test Document " + AutomatedFunctionalTestUtils.DTS);
2643         waitAndClickByName("document.newMaintainableObject.dataObject.number");
2644         waitAndTypeByName("document.newMaintainableObject.dataObject.number", "1234567890");
2645         waitAndTypeByName("document.newMaintainableObject.dataObject.extension.accountTypeCode", "EAT");
2646         waitAndTypeByName("document.newMaintainableObject.dataObject.subAccount", "a1");
2647         waitAndClick(
2648                 "button[data-loadingmessage='Saving...'].uif-action.uif-primaryActionButton.uif-boxLayoutHorizontalItem");
2649         Thread.sleep(2000);
2650 
2651         // checkErrorMessageItem(" also digit validation jira https://jira.kuali.org/browse/KULRICE-8038");
2652         passed();
2653     }
2654 
2655     protected void testVerifySubsidizedPercentWatermarkLegacy() throws Exception {
2656         selectFrameIframePortlet();
2657 
2658         // May be blowing up due to multiple locators
2659         //assertTrue(isElementPresent("//input[@name='document.newMaintainableObject.dataObject.subsidizedPercent' and @type='text' and @placeholder='##.##   ']"));
2660         assertElementPresentByXpath("//input[@name='document.newMaintainableObject.dataObject.subsidizedPercent']");
2661         passed();
2662     }
2663 
2664     protected void typeEnter() {
2665         jGrowl("Press Enter");
2666         driver.switchTo().activeElement().sendKeys(Keys.ENTER);
2667     }
2668 
2669     protected void typeTab() {
2670         jGrowl("Press Tab");
2671         driver.switchTo().activeElement().sendKeys(Keys.TAB);
2672     }
2673 
2674     protected void uncheck(By by) throws InterruptedException {
2675         WebElement element = findElement(by);
2676         if (element.isSelected()) {
2677             element.click();
2678         }
2679     }
2680 
2681     protected void uncheckByName(String name) throws InterruptedException {
2682         uncheck(By.name(name));
2683     }
2684 
2685     protected void uncheckByXpath(String locator) throws InterruptedException {
2686         uncheck(By.xpath(locator));
2687     }
2688 
2689     protected void verifyRichMessagesValidationBasicFunctionality() throws Exception {
2690         assertTrue(isElementPresentByXpath("//input[@type='text' and @name='field1']"));
2691         assertTrue(isElementPresentByXpath("//a[contains(text(), 'Kuali')]"));
2692         assertTrue(isElementPresentByXpath("//input[@type='checkbox' and @name='field2']"));
2693         Thread.sleep(3000);
2694     }
2695 
2696     protected void verifyRichMessagesValidationAdvancedFunctionality() throws Exception {
2697         //Color Options
2698         assertTrue(isElementPresentByXpath("//span[@style='color: green;']"));
2699         assertTrue(isElementPresentByXpath("//span[@style='color: blue;']"));
2700 
2701         //Css class
2702         assertTrue(isElementPresentByXpath("//span[@class='uif-text-underline uif-text-larger']"));
2703 
2704         //Combinations
2705         assertTrue(isElementPresentByXpath("//input[@type='text' and @name='field3']"));
2706         assertTrue(isElementPresentByXpath("//select[@name='field4']"));
2707         assertTrue(isElementPresentByXpath("//button[contains(text(), 'Action Button')]"));
2708 
2709         //Rich Message Field
2710         assertTrue(isElementPresentByXpath("//label[contains(., 'Label With')]/span[contains(., 'Color')]"));
2711         assertTrue(isElementPresentByXpath("//label[contains(., 'Label With')]/i/b[contains(., 'Html')]"));
2712         assertTrue(isElementPresentByXpath("//label[contains(., 'Label With')]/img[@class='uif-image inlineBlock']"));
2713         Thread.sleep(3000);
2714     }
2715 
2716     protected void verifyRichMessagesValidationLettersNumbersValidation() throws Exception {
2717         //For letters only Validation
2718         assertTrue(isElementPresentByXpath("//div[@data-parent='Demo-AdvancedMessagesSection']/div/input[@type='text' and @name='field5']"));
2719         waitAndTypeByXpath(
2720                 "//div[@data-parent='Demo-AdvancedMessagesSection']/div/input[@type='text' and @name='field5']", "abc");
2721         assertFalse(isElementPresentByXpath("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']"));
2722         clearTextByXpath(
2723                 "//div[@data-parent='Demo-AdvancedMessagesSection']/div/input[@type='text' and @name='field5']");
2724         waitAndTypeByXpath("//div[@data-parent='Demo-AdvancedMessagesSection']/div/input[@type='text' and @name='field5']","abc12");
2725         waitAndTypeByXpath("//input[@name= 'field6']", "");
2726         waitForElementPresentByXpath("//div[@class='uif-inputField inlineBlock uif-hasError']");
2727         Thread.sleep(3000);
2728         clearTextByXpath("//div[@data-parent='Demo-AdvancedMessagesSection']/div/input[@type='text' and @name='field5']");
2729         waitAndTypeByXpath("//div[@data-parent='Demo-AdvancedMessagesSection']/div/input[@type='text' and @name='field5']","abc");
2730         waitAndTypeByXpath("//input[@name= 'field6']", "");
2731 
2732         //For numbers only validation
2733         waitAndTypeByXpath("//input[@name= 'field6']", "123");
2734         assertFalse(isElementPresentByXpath("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']"));
2735         clearTextByXpath("//input[@name='field6']");
2736         waitAndTypeByXpath("//input[@name='field6']", "123ab");
2737         fireEvent("field6", "blur");
2738         waitForElementPresentByXpath("//div[@class='uif-inputField inlineBlock uif-hasError']");
2739     }
2740 
2741     protected void verifyRichMessagesValidationRadioAndCheckBoxGroupFunctionality() throws Exception {
2742         //Radio Group
2743         assertTrue(isElementPresentByXpath("//fieldset[@class='uif-verticalRadioFieldset']/span/input[@type='radio' and @name='field24' and @value='1']"));
2744         assertTrue(isElementPresentByXpath(
2745                 "//fieldset[@class='uif-verticalRadioFieldset']/span/input[@type='radio' and @name='field24' and @value='2']"));
2746         assertTrue(isElementPresentByXpath(
2747                 "//fieldset[@class='uif-verticalRadioFieldset']/span/input[@type='radio' and @name='field24' and @value='3']"));
2748         assertTrue(isElementPresentByXpath(
2749                 "//fieldset[@class='uif-verticalRadioFieldset']/span/input[@type='radio' and @name='field24' and @value='4']"));
2750 
2751         //Checkbox Group
2752         assertTrue(isElementPresentByXpath(
2753                 "//fieldset[@class='uif-verticalCheckboxesFieldset']/span/input[@type='checkbox' and @name='field115' and @value='1']"));
2754         assertTrue(isElementPresentByXpath(
2755                 "//fieldset[@class='uif-verticalCheckboxesFieldset']/span/input[@type='checkbox' and @name='field115' and @value='2']"));
2756         assertTrue(isElementPresentByXpath(
2757                 "//fieldset[@class='uif-verticalCheckboxesFieldset']/span/input[@type='checkbox' and @name='field115' and @value='3']"));
2758         assertTrue(isElementPresentByXpath(
2759                 "//fieldset[@class='uif-verticalCheckboxesFieldset']/span/label/div/select[@name='field4']"));
2760 
2761         //Checkbox Control
2762         assertTrue(isElementPresentByXpath("//input[@type='checkbox' and @name='bField1']"));
2763         assertTrue(isElementPresentByXpath("//input[@type='text' and @name='field103']"));
2764     }
2765 
2766     protected void verifyRichMessagesValidationLinkDeclarationsFunctionality() throws Exception {
2767         //Testing link tag
2768         waitAndClickByLinkText("Kuali Site");
2769         Thread.sleep(9000);
2770         switchToWindow("Open Source Software | www.kuali.org");
2771         switchToWindow(RICH_MESSAGES_WINDOW_TITLE);
2772 
2773         //Testing methodToCall Action
2774         waitAndClickByXpath("//p[contains(., 'Testing methodToCall action')]/a");
2775         Thread.sleep(3000);
2776         assertTrue(isElementPresentByXpath(
2777                 "//div[@class='alert alert-danger']"));
2778 
2779         //Testing methodToCall action (no client validation check)
2780         waitAndClickByXpath("//p[contains(., 'Testing methodToCall action (no client validation check)')]/a");
2781         assertTrue(isElementPresentByXpath("//div[@id='Demo-BasicMessagesSection_messages' and @class='alert alert-danger']"));
2782         assertTrue(isElementPresentByXpath("//div[@id='Demo-AdvancedMessagesSection_messages' and @class='alert alert-danger']"));
2783         Thread.sleep(3000);
2784     }
2785 
2786     protected void waitAndClickAdministration() throws InterruptedException {
2787         waitAndClickByLinkText(ADMINISTRATION_LINK_TEXT, this);
2788     }
2789 
2790     protected void waitAndClickClearValues() throws InterruptedException {
2791         waitAndClickButtonByText("Clear Values");
2792     }
2793 
2794     /**
2795      * {@link #ADMINISTRATION_LINK_TEXT}
2796      * @param failable
2797      * @throws InterruptedException
2798      */
2799     private void waitAndClickAdministration(JiraAwareFailable failable) throws InterruptedException {
2800         waitAndClickByLinkText(ADMINISTRATION_LINK_TEXT, failable);
2801     }
2802 
2803     protected void waitAndCancelConfirmation() throws InterruptedException {
2804         waitAndClickCancel();
2805         waitAndClickByName("methodToCall.processAnswer.button0");
2806     }
2807 
2808     protected void waitAndClickAdHocPersonAdd() throws InterruptedException  {
2809         jGrowl("Click AdHoc Person add");
2810         waitAndClickByXpath("//button[@id='Uif-AdHocPersonCollection_add']");
2811     }
2812 
2813     protected void waitAndClickAdHocPersonAddQuickFinder() throws InterruptedException  {
2814         jGrowl("Click AdHoc Person quickfinder");
2815         waitAndClickByXpath("//div[@data-parent='Uif-AdHocPersonCollection']/div/div/button");
2816     }
2817 
2818     protected void waitAndClickAdHocGroupAddQuickFinder() throws InterruptedException  {
2819         jGrowl("Click AdHoc Group quickfinder");
2820         waitAndClickByXpath("//div[@data-parent='CollectionGroup_AdHocWorkgroup']/div/div/button");
2821     }
2822 
2823     protected void waitAndClickBlanketApprove() throws InterruptedException {
2824         waitAndClickButtonByText("Blanket Approve");
2825     }
2826 
2827     /**
2828      * {@link #CANCEL_NAME}
2829      * @throws InterruptedException
2830      */
2831     protected void waitAndClickCancel() throws InterruptedException {
2832         waitAndClickByName(CANCEL_NAME);
2833     }
2834 
2835     protected void waitAndClickCancelByText() throws InterruptedException {
2836         waitAndClickButtonByText("Cancel");
2837     }
2838 
2839     /**
2840      * {@link #CLOSE_WINDOW_XPATH_TITLE}
2841      * @throws InterruptedException
2842      */
2843     protected void waitAndClickCloseWindow() throws InterruptedException {
2844         waitAndClickByXpath(CLOSE_WINDOW_XPATH_TITLE);
2845     }
2846 
2847     /**
2848      * {@link #COPY_LINK_TEXT}
2849      * @throws InterruptedException
2850      */
2851     protected void waitAndClickCopy() throws InterruptedException {
2852         waitAndClickByLinkText(COPY_LINK_TEXT);
2853     }
2854 
2855     protected void waitAndClickDemoLink() throws InterruptedException {
2856         jGrowl("Click Demo Link");
2857         waitAndClickById("Demo-DemoLink", "");
2858     }
2859 
2860     /**
2861      * {}@link #DOC_SEARCH_XPATH}
2862      * @throws InterruptedException
2863      */
2864     protected void waitAndClickDocSearch() throws InterruptedException {
2865         waitAndClickByXpath(DOC_SEARCH_XPATH);
2866     }
2867 
2868     /**
2869      * {@link #DOC_SEARCH_XPATH_TITLE}
2870      * @throws InterruptedException
2871      */
2872     protected void waitAndClickDocSearchTitle() throws InterruptedException {
2873         waitAndClickByXpath(DOC_SEARCH_XPATH_TITLE);
2874     }
2875 
2876     protected void waitAndClickLibraryLink() throws InterruptedException {
2877         jGrowl("Click Library Link");
2878         waitAndClickById("Demo-LibraryLink", "");
2879     }
2880 
2881     /**
2882      * {@link #LOGOUT_XPATH}
2883      * @throws InterruptedException
2884      */
2885     protected void waitAndClickLogout() throws InterruptedException {
2886         waitAndClickLogout(this);
2887     }
2888 
2889     /**
2890      * {@link #LOGOUT_XPATH}
2891      * @param failable
2892      * @throws InterruptedException
2893      */
2894     protected void waitAndClickLogout(JiraAwareFailable failable) throws InterruptedException {
2895         jGrowl("Logging out");
2896         selectTopFrame();
2897         waitAndClickByXpath(LOGOUT_XPATH, failable);
2898     }
2899 
2900     protected void waitAndClickMainMenu() throws InterruptedException {
2901         waitAndClickByLinkText(MAIN_MENU_LINK_TEXT, this);
2902     }
2903 
2904     /**
2905      * {}@link #MAIN_MENU_LINK_TEXT}
2906      * @param failable
2907      * @throws InterruptedException
2908      */
2909     private void waitAndClickMainMenu(JiraAwareFailable failable) throws InterruptedException {
2910         waitAndClickByLinkText(MAIN_MENU_LINK_TEXT, failable);
2911     }
2912 
2913     protected void waitAndClickRouteLogIcon() throws InterruptedException {
2914         jGrowl("Click Route Log link");
2915         waitAndClickByXpath("//img[@alt=\"Route Log for Document\"]");
2916     }
2917 
2918     /**
2919      * {@link #SAVE_XPATH}
2920      * @throws InterruptedException
2921      */
2922     protected void waitAndClickSave() throws InterruptedException {
2923         waitAndClickByXpath(SAVE_XPATH);
2924     }
2925 
2926     protected void waitAndClickSaveByText() throws InterruptedException {
2927         waitAndClickButtonByText("Save");
2928     }
2929 
2930     /**
2931      * {@link #SUBMIT_XPATH}
2932      * @throws InterruptedException
2933      */
2934     protected void waitAndClickSubmit() throws InterruptedException {
2935         jGrowl("Click Submit");
2936         waitAndClickByXpath(SUBMIT_XPATH);
2937     }
2938 
2939     protected void waitAndClickSubmitByText() throws InterruptedException {
2940         waitAndClickButtonByText("Submit");
2941     }
2942 
2943     /**
2944      * {@link #APPROVE_XPATH}
2945      * @throws InterruptedException
2946      */
2947     protected void waitAndClickApprove() throws InterruptedException {
2948         jGrowl("Click Approve");
2949         waitAndClickByXpath(APPROVE_XPATH);
2950     }
2951 
2952     protected void waitAndClickApproveByText() throws InterruptedException {
2953         waitAndClickButtonByText("Approve");
2954     }
2955 
2956     /**
2957      * {@link #DISAPPROVE_XPATH}
2958      * @throws InterruptedException
2959      */
2960     protected void waitAndClickDisapprove() throws InterruptedException {
2961         jGrowl("Click Disapprove");
2962         waitAndClickByXpath(DISAPPROVE_XPATH);
2963     }
2964 
2965     protected void waitAndClickDisapproveByText() throws InterruptedException {
2966         waitAndClickButtonByText("Disapprove");
2967     }
2968 
2969     /**
2970      * {@link #ACKNOWLEDGE_XPATH}
2971      * @throws InterruptedException
2972      */
2973     protected void waitAndClickAcknowledge() throws InterruptedException {
2974         jGrowl("Click Acknowledge");
2975         waitAndClickByXpath(ACKNOWLEDGE_XPATH);
2976     }
2977 
2978     protected void waitAndClickAcknowledgeByText() throws InterruptedException {
2979         waitAndClickButtonByText("Acknowledge");
2980     }
2981 
2982     /**
2983      * {@link #CLOSE_XPATH}
2984      * @throws InterruptedException
2985      */
2986     protected void waitAndClickClose() throws InterruptedException {
2987         jGrowl("Click Close");
2988         waitAndClickByXpath(CLOSE_XPATH);
2989     }
2990 
2991     protected void waitAndClickCloseByText() throws InterruptedException {
2992         waitAndClickButtonByText("Close");
2993     }
2994 
2995     /**
2996      * {@link #XML_INGESTER_LINK_TEXT}
2997      * @param failable
2998      * @throws InterruptedException
2999      */
3000     protected void waitAndClickXMLIngester(JiraAwareFailable failable) throws InterruptedException {
3001         waitAndClickByLinkText(XML_INGESTER_LINK_TEXT, failable);
3002     }
3003 
3004     protected void waitAndCreateNew() throws InterruptedException {
3005         waitAndCreateNew(this.getClass().toString());
3006     }
3007 
3008     protected void waitAndCreateNew(String message) throws InterruptedException {
3009         selectFrameIframePortlet();
3010         jGrowl("Create New");
3011         waitAndClickCreateNew(message);
3012     }
3013 
3014     /**
3015      * {@link #CREATE_NEW_XPATH}
3016      * @throws InterruptedException
3017      */
3018     protected void waitAndClickCreateNew() throws InterruptedException {
3019         waitAndClickCreateNew(this.getClass().toString());
3020     }
3021 
3022     protected void waitAndClickCreateNew(String message) throws InterruptedException {
3023         jGrowl("Click Create New");
3024         if (WebDriverUtils.waitFors(driver, By.xpath(CREATE_NEW_XPATH)).size() > 0) {
3025             waitAndClickByXpath(CREATE_NEW_XPATH, message);
3026         } else {
3027             System.out.println("waitAndClickByXpath(" + CREATE_NEW_XPATH + ") wasn't found trying " + CREATE_NEW_XPATH2);
3028             waitAndClickByXpath(CREATE_NEW_XPATH2, message);
3029         }
3030     }
3031 
3032     protected void waitAndClickEdit() throws InterruptedException {
3033         waitAndClickByLinkText(EDIT_LINK_TEXT);
3034     }
3035 
3036     /**
3037      * {@link #SEARCH_XPATH}
3038      * @throws InterruptedException
3039      */
3040     protected void waitAndClickSearch() throws InterruptedException {
3041         jGrowl("Click Search");
3042         waitAndClickByXpath(SEARCH_XPATH);
3043     }
3044 
3045     protected void waitAndClickSearch2() throws InterruptedException {
3046         jGrowl("Click Search");
3047         waitAndClickByXpath(SEARCH_XPATH_2);
3048     }
3049 
3050     protected void waitAndClickSearchSecond() throws InterruptedException {
3051         jGrowl("Click Search");
3052         waitAndClickByXpath(SEARCH_SECOND);
3053     }
3054 
3055     protected void waitAndClickSearchByText() throws InterruptedException {
3056         waitAndClickButtonByText("Search");
3057     }
3058 
3059     protected String waitForAgendaDocId() throws InterruptedException {
3060         String docId = waitForElementPresentByXpath("//div[@data-label=\"Document Number\"]").getText();
3061         jGrowl("Document Number is " + docId);
3062         return docId;
3063     }
3064 
3065     protected String waitForDocId() throws InterruptedException {
3066         checkForDocError();
3067         waitForElementPresentByXpath(DOC_ID_XPATH);
3068         String docId = findElement(By.xpath(DOC_ID_XPATH)).getText();
3069         jGrowl("Document Number is " + docId);
3070         return docId;
3071     }
3072 
3073     protected String waitForDocIdKrad() throws InterruptedException {
3074         failOnErrorMessageItem();
3075         waitForElementPresentByXpath(DOC_ID_KRAD_XPATH);
3076         String docId = findElement(By.xpath(DOC_ID_KRAD_XPATH)).getText();
3077         jGrowl("Document Number is " + docId);
3078 
3079         return docId;
3080     }
3081 
3082     protected String waitForDocInitiator() throws InterruptedException {
3083         waitForElementPresentByXpath(DOC_INITIATOR_XPATH);
3084 
3085         return findElement(By.xpath(DOC_INITIATOR_XPATH)).getText();
3086     }
3087 
3088     protected String waitForDocStatus() throws InterruptedException {
3089         waitForElementPresentByXpath(DOC_STATUS_XPATH);
3090 
3091         return findElement(By.xpath(DOC_STATUS_XPATH)).getText();
3092     }
3093 
3094     protected void waitForTitleToEqualKualiPortalIndex() throws InterruptedException {
3095         waitForTitleToEqualKualiPortalIndex(this.getClass().toString());
3096     }
3097 
3098     protected void waitForToolTipTextPresent(String tooltipText) throws InterruptedException {
3099         assertEquals("ToolTip text not as expected", tooltipText, waitForToolTipPresent().getText());
3100     }
3101 
3102     protected WebElement waitForToolTipPresent() throws InterruptedException {
3103         waitForElementPresent(".popover.top.in");
3104         WebElement tooltip = findElement(By.cssSelector(".popover.top.in"));
3105         jGrowl("ToolTip " + tooltip.getText());
3106         return tooltip;
3107     }
3108 
3109     protected void waitForTitleToEqualKualiPortalIndex(String message) throws InterruptedException {
3110         Thread.sleep(2000);
3111         // This started failing in CI....
3112         // boolean failed = false;
3113         //
3114         // for (int second = 0;; second++) {
3115         //     Thread.sleep(1000);
3116         //     if (second >= waitSeconds) failed = true;
3117         //     try { if (failed || ITUtil.KUALI_PORTAL_TITLE.equals(driver.getTitle())) break; } catch (Exception e) {}
3118         // }
3119 
3120         // WebDriverUtils.checkForIncidentReport(driver, message); // after timeout to be sure page is loaded
3121         // if (failed) jiraAwareFail("timeout of " + waitSeconds + " seconds " + message);
3122     }
3123 
3124     /**
3125      * {@link #KRAD_XPATH}
3126      * @throws InterruptedException
3127      */
3128     protected void waitAndClickKRAD() throws InterruptedException {
3129         waitAndClickByLinkText(KRAD_XPATH);
3130     }
3131 
3132     /**
3133      * Does the test page use KRAD UIF?
3134      * Useful if trying to re-use a test for both a KNS and KRAD screens that have different paths to the elements.
3135      * @return
3136      */
3137     protected boolean isKrad(){
3138         return (AutomatedFunctionalTestUtils.REMOTE_UIF_KRAD.equalsIgnoreCase(getUiFramework()));
3139     }
3140 
3141     /**
3142      * Determines whether KRAD or KNS UIF is used for this test.
3143      * Useful if trying to re-use a test for both a KNS and KRAD screens that have different paths to the elements.
3144      * @return
3145      */
3146     public String getUiFramework() {
3147         return uiFramework;
3148     }
3149 
3150     /**
3151      * Sets which UIF is used by this test
3152      */
3153     public void setUiFramework(String uiFramework) {
3154         this.uiFramework = uiFramework;
3155     }
3156     
3157     /**
3158      * presses Enter Key by Name
3159      */
3160     public void pressEnterByName(String locator){
3161     	pressEnter(By.name(locator));
3162     }
3163     
3164     /**
3165      * presses Enter Key by Xpath
3166      */
3167     public void pressEnterByXpath(String locator){
3168     	pressEnter(By.xpath(locator));
3169     }
3170     
3171     /**
3172      * presses Enter Key
3173      */
3174     public void pressEnter(By by){
3175     	 findElement(by).sendKeys(Keys.ENTER);
3176     }
3177 }