View Javadoc

1   /*
2    * Copyright 2006-2012 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  
17  package edu.samplu.krad.compview;
18  
19  import edu.samplu.common.ITUtil;
20  import edu.samplu.common.WebDriverLegacyITBase;
21  
22  import org.junit.Test;
23  import org.openqa.selenium.internal.seleniumemulation.GetValue;
24  
25  import static org.junit.Assert.assertNotSame;
26  import static org.junit.Assert.fail;
27  
28  /**
29   * tests that a line in a sub collection can be deleted
30   *
31   * @author Kuali Rice Team (rice.collab@kuali.org)
32   */
33  public class DeleteSubCollectionLineLegacyIT extends WebDriverLegacyITBase{
34      @Override
35      public String getTestUrl() {
36          return  "/kr-krad/uicomponents?viewId=UifCompView_KNS&methodToCall=start&readOnlyFields=field91";
37      }
38  
39      @Test
40      /**
41       * tests that a line in a sub collection can be deleted
42       */
43      public void deleteSubCollectionLine() throws Exception {
44          // click on collections page link
45          waitAndClickByLinkText("Collections");
46          Thread.sleep(5000);
47          // wait for collections page to load by checking the presence of a sub collection line item
48  
49          waitForElementPresentByName("list4[0].subList[0].field1");
50          // change a value in the line to be deleted
51          waitAndTypeByName("list4[0].subList[0].field1", "selenium");
52          // click the delete button
53          waitAndClick("div[title='Line Summary \\'A\\' With Expression'].uif-group.uif-gridGroup.uif-collectionItem.uif-gridCollectionItem div.uif-group.uif-collectionGroup.uif-tableCollectionGroup.uif-tableSubCollection.uif-disclosure tr.odd button[data-loadingmessage='Deleting Line...'].uif-action.uif-secondaryActionButton.uif-smallActionButton");
54  //        waitAndClickByXpath("//div[@title='Line Summary \'A\' With Expression']/table/tbody/tr[1]/td[5]/div/fieldset/div/div[@class='uif-boxLayout uif-horizontalBoxLayout clearfix']/button[@data-loadingmessage='Deleting Line...']");
55          Thread.sleep(2000);
56          // confirm that the input box containing the modified value is not present
57          
58          for (int second = 0;; second++) {
59              if (second >= 60) fail("timeout");
60              try { 
61                  System.out.println("Loop ----- "+second);
62                  if (!"selenium".equals(getAttributeByName("list4[0].subList[0].field1","value")))
63                      break;
64                  } catch (Exception e) {}
65              Thread.sleep(1000);
66          }
67          // verify that the value has changed for the input box in the line that has replaced the deleted one
68          assertNotSame("selenium", getAttributeByName("list4[0].subList[0].field1","value"));
69          passed();
70      }
71  }