001 /*
002 * Copyright 2006-2012 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
017 package edu.samplu.krad.compview;
018
019 import com.thoughtworks.selenium.*;
020 import org.junit.After;
021 import org.junit.Before;
022 import org.junit.Test;
023 import java.util.regex.Pattern;
024 import static org.junit.Assert.assertNotSame;
025 import static org.junit.Assert.fail;
026
027 /**
028 * tests that a line in a sub collection can be deleted
029 *
030 * @author Kuali Rice Team (rice.collab@kuali.org)
031 */
032 public class DeleteSubCollectionLineIT {
033 private DefaultSelenium selenium;
034
035 @Before
036 public void setUp() throws Exception {
037 selenium = new DefaultSelenium("localhost", 4444, "*chrome", System.getProperty("remote.public.url"));//"http://localhost:8080/"
038 selenium.start();
039 }
040
041 @Test
042 /**
043 * tests that a line in a sub collection can be deleted
044 */
045 public void deleteSubCollectionLine() throws Exception {
046 selenium.open("/kr-dev/portal.do");
047 selenium.type("name=__login_user", "admin");
048 selenium.click("css=input[type=\"submit\"]");
049 selenium.waitForPageToLoad("30000");
050 selenium.click("link=KRAD");
051 selenium.waitForPageToLoad("30000");
052 selenium.click("link=Uif Components (Kitchen Sink)");
053 selenium.waitForPageToLoad("30000");
054 selenium.selectFrame("iframeportlet");
055 // click on collections page link
056 selenium.click("id=u961");
057 // Thread.sleep(30000);
058 // wait for collections page to load by checking the presence of a sub collection line item
059 for (int second = 0;; second++) {
060 if (second >= 60) fail("timeout");
061 try { if (selenium.isElementPresent("id=u1089_line0_line0_control")) break; } catch (Exception e) {}
062 Thread.sleep(1000);
063 }
064 // change a value in the line to be deleted
065 selenium.type("id=u1089_line0_line0_control", "selenium");
066 // click the delete button
067 selenium.click("id=u1140_line0_line0");
068 // confirm that the input box containing the modified value is not present
069 for (int second = 0;; second++) {
070 if (second >= 60) fail("timeout");
071 try { if (!"selenium".equals(selenium.getValue("id=u1089_line0_line0_control"))) break; } catch (Exception e) {}
072 Thread.sleep(1000);
073 }
074 // verify that the value has changed for the input box in the line that has replaced the deleted one
075 assertNotSame("selenium", selenium.getValue("id=u1089_line0_line0_control"));
076 }
077
078 @After
079 public void tearDown() throws Exception {
080 selenium.stop();
081 }
082 }