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