View Javadoc

1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package edu.sampleu.krad.compview;
17  
18  import org.kuali.rice.testtools.common.JiraAwareFailable;
19  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
20  
21  import static org.junit.Assert.assertNotSame;
22  
23  /**
24   * Tests the Component section in Rice.
25   *
26   * @author Kuali Rice Team (rice.collab@kuali.org)
27   */
28  public abstract class DeleteSubCollectionLineAftBase extends WebDriverLegacyITBase {
29  
30      /**
31       * /kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&readOnlyFields=field91
32       */
33      public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&readOnlyFields=field91";
34      
35      /**
36       * list4[0].subList[0].field1
37       */
38      public static final String FIELD_ELEMENT_NAME = "list4[0].subList[0].field1";
39      
40      @Override
41      protected String getBookmarkUrl() {
42          return BOOKMARK_URL;
43      }
44  
45      protected void navigation() throws Exception {
46          waitAndClickKRAD();
47          waitAndClickByXpath(KITCHEN_SINK_XPATH);
48          switchToWindow(KUALI_UIF_COMPONENTS_WINDOW_XPATH);
49      }
50  
51      protected void testDeleteSubCollectionLineNav(JiraAwareFailable failable) throws Exception {
52          navigation();
53          testDeleteSubCollectionLine();
54          passed();
55      }
56  
57      protected void testDeleteSubCollectionLineBookmark(JiraAwareFailable failable) throws Exception {
58          testDeleteSubCollectionLine();
59          passed();
60      }
61  
62      protected void testDeleteSubCollectionLine() throws Exception {
63          // click on collections page link
64          waitAndClickByLinkText(COLLECTIONS_LINK_TEXT);
65          Thread.sleep(5000);
66  
67          // wait for collections page to load by checking the presence of a sub collection line item
68          waitForElementPresentByName(FIELD_ELEMENT_NAME);
69  
70          // change a value in the line to be deleted
71          waitAndTypeByName(FIELD_ELEMENT_NAME, "selenium");
72  
73          // click the delete button
74          waitAndClickById("subCollection1_line0_del_line0_line0");
75          Thread.sleep(2000);
76  
77          // confirm that the input box containing the modified value is not present
78          for (int second = 0;; second++) {
79              if (second >= waitSeconds)fail(TIMEOUT_MESSAGE);
80              
81              try {
82                  if (!"selenium".equals(waitAndGetAttributeByName(FIELD_ELEMENT_NAME, "value")))
83                      break;
84              } catch (Exception e) {}
85              
86              Thread.sleep(1000);
87          }
88  
89          // verify that the value has changed for the input box in the line that has replaced the deleted one
90          assertNotSame("selenium", waitAndGetAttributeByName(FIELD_ELEMENT_NAME, "value"));
91      }
92  }