1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.samplu.travel.krad.test;
17
18 import com.thoughtworks.selenium.DefaultSelenium;
19 import com.thoughtworks.selenium.Selenium;
20 import org.junit.After;
21 import org.junit.Before;
22 import org.junit.Test;
23
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertTrue;
26
27
28
29
30
31
32 public class WatermarkValidationIT {
33 private Selenium selenium;
34
35 @Before
36 public void setUp() throws Exception {
37 selenium = new DefaultSelenium("localhost", 4444, "*firefox", System.getProperty("remote.public.url"));
38 selenium.start();
39 }
40
41 @Test
42
43
44
45
46 public void testWatermarking() throws Exception {
47 selenium.open(System.getProperty("remote.public.url"));
48 selenium.type("name=__login_user", "quickstart");
49 selenium.click("css=input[type=\"submit\"]");
50 selenium.waitForPageToLoad("100000");
51 selenium.click("link=KRAD");
52 selenium.waitForPageToLoad("50000");
53 selenium.click("link=Uif Components (Kitchen Sink)");
54 selenium.waitForPageToLoad("100000");
55 selenium.selectFrame("iframeportlet");
56 selenium.focus("id=u73_control");
57 selenium.type("id=u73_control", "something");
58 selenium.focus("id=u103_control");
59 selenium.type("id=u103_control", "something else");
60 assertEquals("something", selenium.getValue("xpath=//*[@id=\"u73_control\"]"));
61 selenium.chooseCancelOnNextConfirmation();
62
63 selenium.click("id=u29");
64 assertTrue(selenium.getConfirmation().matches("^Form has unsaved data\\. Do you want to leave anyway[\\s\\S]$"));
65 }
66
67 @After
68 public void tearDown() throws Exception {
69 selenium.stop();
70 }
71
72 public void clearText(String field) throws Exception {
73 selenium.focus(field);
74 selenium.type(field, "");
75 Thread.sleep(100);
76 }
77 }