1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package edu.samplu.krad.compview;
18
19 import com.thoughtworks.selenium.Selenium;
20 import junit.framework.Assert;
21 import org.junit.After;
22 import org.junit.Before;
23 import org.junit.Test;
24 import org.openqa.selenium.WebDriver;
25 import org.openqa.selenium.WebDriverBackedSelenium;
26 import org.openqa.selenium.firefox.FirefoxDriver;
27
28
29
30
31
32
33
34 public class UifTooltipIT {
35 private Selenium selenium;
36
37 @Before
38 public void setUp() throws Exception {
39 WebDriver driver = new FirefoxDriver();
40 String baseUrl = "http://localhost:8080/";
41 selenium = new WebDriverBackedSelenium(driver, baseUrl);
42 }
43
44 @Test
45 public void testTooltip() throws Exception {
46
47 selenium.open(
48 "http://localhost:8080/kr-dev/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&pageId=UifCompView-Page10");
49 selenium.type("name=__login_user", "admin");
50 selenium.click("//input[@value='Login']");
51 selenium.waitForPageToLoad("30000");
52
53 selenium.fireEvent("name=field1", "focus");
54 Assert.assertTrue(selenium.isVisible(
55 "//td[contains(.,\"This tooltip is triggered by focus or and mouse over.\")]"));
56
57 selenium.fireEvent("name=field1", "blur");
58 Assert.assertFalse(selenium.isVisible(
59 "//td[contains(.,\"This tooltip is triggered by focus or and mouse over.\")]"));
60
61 selenium.mouseOver("name=field2");
62 Assert.assertTrue(selenium.isVisible(
63 "//td[contains(.,\"This is a tool-tip with different position and tail options\")]"));
64
65 selenium.mouseOut("name=field2");
66 Assert.assertFalse(selenium.isVisible(
67 "//td[contains(.,\"This is a tool-tip with different position and tail options\")]"));
68
69 selenium.type("name=field1", "1");
70 selenium.fireEvent("name=field1", "blur");
71 selenium.fireEvent("name=field1", "focus");
72 Assert.assertFalse(selenium.isVisible(
73 "//td[contains(.,\"This tooltip is triggered by focus or and mouse over.\")]"));
74 }
75
76 @After
77 public void tearDown() throws Exception {
78 selenium.stop();
79 }
80
81 }