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.samplu.krad.compview;
17  
18  import static org.junit.Assert.assertNotSame;
19  
20  import edu.samplu.common.Failable;
21  import edu.samplu.common.ITUtil;
22  import edu.samplu.common.WebDriverLegacyITBase;
23  
24  /**
25   * Tests the Component section in Rice.
26   *
27   * @author Kuali Rice Team (rice.collab@kuali.org)
28   */
29  public abstract class DeleteSubCollectionLineAbstractSmokeTestBase extends WebDriverLegacyITBase {
30  
31      /**
32       * /kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&readOnlyFields=field91
33       */
34      public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&readOnlyFields=field91";
35      
36      /**
37       * list4[0].subList[0].field1
38       */
39      public static final String FIELD_ELEMENT_NAME = "list4[0].subList[0].field1";
40      
41      /**
42       * Nav tests start at {@link edu.samplu.common.ITUtil#PORTAL}.  Bookmark Tests should override and return {@link DeleteSubCollectionLineAbstractSmokeTestBase#BOOKMARK_URL}
43       * {@inheritDoc}
44       * @return
45       */    
46      @Override
47      public String getTestUrl() {
48          return ITUtil.PORTAL;
49      }
50  
51      protected void navigation() throws Exception {
52          waitAndClickKRAD();
53          waitAndClickByXpath(KITCHEN_SINK_XPATH);
54          switchToWindow(KUALI_UIF_COMPONENTS_WINDOW_XPATH);
55      }
56  
57      protected void testDeleteSubCollectionLineNav(Failable failable) throws Exception {
58          navigation();
59          testDeleteSubCollectionLine();
60          passed();
61      }
62  
63      protected void testDeleteSubCollectionLineBookmark(Failable failable) throws Exception {
64          testDeleteSubCollectionLine();
65          passed();
66      }
67  
68      protected void testDeleteSubCollectionLine() throws Exception {
69          // click on collections page link
70          waitAndClickByLinkText(COLLECTIONS_LINK_TEXT);
71          Thread.sleep(5000);
72  
73          // wait for collections page to load by checking the presence of a sub collection line item
74          waitForElementPresentByName(FIELD_ELEMENT_NAME);
75  
76          // change a value in the line to be deleted
77          waitAndTypeByName(FIELD_ELEMENT_NAME, "selenium");
78  
79          // click the delete button
80          waitAndClickById("subCollection1_line0_del_line0_line0");
81          Thread.sleep(2000);
82  
83          // confirm that the input box containing the modified value is not present
84          for (int second = 0;; second++) {
85              if (second >= waitSeconds)fail(TIMEOUT_MESSAGE);
86              
87              try {
88                  if (!"selenium".equals(getAttributeByName(FIELD_ELEMENT_NAME, "value")))
89                      break;
90              } catch (Exception e) {}
91              
92              Thread.sleep(1000);
93          }
94  
95          // verify that the value has changed for the input box in the line that has replaced the deleted one
96          assertNotSame("selenium", getAttributeByName(FIELD_ELEMENT_NAME, "value"));
97      }
98  }