1 package edu.samplu.krad.demo.uif.library;
2
3 import com.thoughtworks.selenium.SeleneseTestBase;
4 import org.junit.Test;
5 import org.openqa.selenium.By;
6 import org.openqa.selenium.WebElement;
7
8
9
10
11 public class DemoLibraryFieldsLinkSmokeTest extends DemoLibraryBase {
12
13
14
15
16 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-LinkField-View&methodToCall=start";
17
18 @Override
19 public String getBookmarkUrl() {
20 return BOOKMARK_URL;
21 }
22
23 @Override
24 protected void navigate() throws Exception {
25 navigateToLibraryDemo("Fields", "Link Field");
26 }
27
28 protected void testLinkFieldDefault() throws Exception {
29 WebElement exampleDiv = navigateToExample("Demo-LinkField-Example1");
30 WebElement field = findElement(By.cssSelector(".uif-link"), exampleDiv);
31
32 String fieldId = field.getAttribute("id");
33
34 assertIsVisible("#" + fieldId);
35 waitAndClickByLinkText(field.getText());
36
37 Thread.sleep(2000);
38
39 assertTextPresent("Kuali Foundation");
40
41 driver.navigate().back();
42 }
43
44 protected void testLinkFieldCustomTarget() throws Exception {
45 WebElement exampleDiv = navigateToExample("Demo-LinkField-Example2");
46 WebElement field = findElement(By.cssSelector(".uif-link"), exampleDiv);
47
48 String fieldId = field.getAttribute("id");
49
50 assertIsVisible("#" + fieldId);
51 waitAndClickByLinkText(field.getText());
52
53 Thread.sleep(2000);
54
55 switchToWindow("Kuali Foundation");
56
57 SeleneseTestBase.assertEquals("http://www.kuali.org/", driver.getCurrentUrl());
58 driver.close();
59
60 switchToWindow("Kuali");
61 }
62
63 protected void testLinkFieldLightbox() throws Exception {
64 WebElement exampleDiv = navigateToExample("Demo-LinkField-Example3");
65 WebElement field = findElement(By.cssSelector(".uif-link"), exampleDiv);
66
67 String fieldId = field.getAttribute("id");
68
69 assertIsVisible("#" + fieldId);
70 waitAndClickByLinkText(field.getText());
71
72 WebElement lightboxIFrame = driver.findElement(By.cssSelector(".fancybox-iframe"));
73 if (!lightboxIFrame.getAttribute("src").contains("www.kuali.org")) {
74 fail("Lightbox did not appear");
75 }
76 }
77
78 protected void testLinkFieldExamples() throws Exception {
79 testLinkFieldDefault();
80 testLinkFieldCustomTarget();
81 testLinkFieldLightbox();
82 }
83
84 @Test
85 public void testLinkFieldExamplesBookmark() throws Exception {
86 testLinkFieldExamples();
87 passed();
88 }
89
90 @Test
91 public void testLinkFieldExamplesNav() throws Exception {
92 testLinkFieldExamples();
93 passed();
94 }
95
96 @Test
97 public void testLinkFieldDefaultBookmark() throws Exception {
98 testLinkFieldDefault();
99 passed();
100 }
101
102 @Test
103 public void testLinkFieldDefaultNav() throws Exception {
104 testLinkFieldDefault();
105 passed();
106 }
107
108 @Test
109 public void testLinkFieldCustomTargetBookmark() throws Exception {
110 testLinkFieldCustomTarget();
111 passed();
112 }
113
114 @Test
115 public void testLinkFieldCustomTargetNav() throws Exception {
116 testLinkFieldCustomTarget();
117 passed();
118 }
119
120 @Test
121 public void testLinkFieldLightboxBookmark() throws Exception {
122 testLinkFieldLightbox();
123 passed();
124 }
125
126 @Test
127 public void testLinkFieldLightboxNav() throws Exception {
128 testLinkFieldLightbox();
129 passed();
130 }
131 }