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