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 com.thoughtworks.selenium.*;
20  import org.junit.After;
21  import org.junit.Before;
22  import org.junit.Test;
23  import java.util.regex.Pattern;
24  import static org.junit.Assert.assertNotSame;
25  import static org.junit.Assert.fail;
26  
27  /**
28   * tests that a line in a sub collection can be deleted
29   *
30   * @author Kuali Rice Team (rice.collab@kuali.org)
31   */
32  public class DeleteSubCollectionLineIT {
33      private DefaultSelenium selenium;
34  
35      @Before
36      public void setUp() throws Exception {
37          selenium = new DefaultSelenium("localhost", 4444, "*chrome",  System.getProperty("remote.public.url"));//"http://localhost:8080/"
38          selenium.start();
39      }
40  
41      @Test
42      /**
43       * tests that a line in a sub collection can be deleted
44       */
45      public void deleteSubCollectionLine() throws Exception {
46          selenium.open("/kr-dev/portal.do");
47          selenium.type("name=__login_user", "admin");
48          selenium.click("css=input[type=\"submit\"]");
49          selenium.waitForPageToLoad("30000");
50          selenium.click("link=KRAD");
51          selenium.waitForPageToLoad("30000");
52          selenium.click("link=Uif Components (Kitchen Sink)");
53          selenium.waitForPageToLoad("30000");
54          selenium.selectFrame("iframeportlet");
55          // click on collections page link
56          selenium.click("id=u961");
57          // Thread.sleep(30000);
58          // wait for collections page to load by checking the presence of a sub collection line item
59          for (int second = 0;; second++) {
60              if (second >= 60) fail("timeout");
61              try { if (selenium.isElementPresent("id=u1089_line0_line0_control")) break; } catch (Exception e) {}
62              Thread.sleep(1000);
63          }
64          // change a value in the line to be deleted
65          selenium.type("id=u1089_line0_line0_control", "selenium");
66          // click the delete button
67          selenium.click("id=u1140_line0_line0");
68          // confirm that the input box containing the modified value is not present
69          for (int second = 0;; second++) {
70              if (second >= 60) fail("timeout");
71              try { if (!"selenium".equals(selenium.getValue("id=u1089_line0_line0_control"))) break; } catch (Exception e) {}
72              Thread.sleep(1000);
73          }
74          // verify that the value has changed for the input box in the line that has replaced the deleted one
75          assertNotSame("selenium", selenium.getValue("id=u1089_line0_line0_control"));
76      }
77  
78      @After
79      public void tearDown() throws Exception {
80          selenium.stop();
81      }
82  }