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