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 WatermarkValidation {
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
57 selenium.focus("id=257");
58 selenium.type("id=257", "something");
59 selenium.focus("id=371");
60 selenium.type("id=371", "something else");
61 assertEquals("something", selenium.getValue("xpath=//*[@id=\"257\"]"));
62 selenium.chooseCancelOnNextConfirmation();
63 selenium.click("id=10");
64
65
66 assertTrue(selenium.getConfirmation().matches("^Form has unsaved data\\. Do you want to leave anyway[\\s\\S]$"));
67 }
68
69 @After
70 public void tearDown() throws Exception {
71 selenium.stop();
72 }
73
74 public void clearText(String field) throws Exception {
75 selenium.focus(field);
76 selenium.type(field, "");
77 Thread.sleep(100);
78 }
79 }