1 package edu.samplu.krad.demo.uif.library;
2
3 import org.junit.Test;
4 import org.openqa.selenium.By;
5 import org.openqa.selenium.WebElement;
6
7
8
9
10 public class DemoLibraryFieldsImageSmokeTest extends DemoLibraryBase {
11
12
13
14
15 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-ImageField-View&methodToCall=start";
16
17 @Override
18 public String getBookmarkUrl() {
19 return BOOKMARK_URL;
20 }
21
22 @Override
23 protected void navigate() throws Exception {
24 navigateToLibraryDemo("Fields", "Image Field");
25 }
26
27 protected void testImageFieldDefault() throws Exception {
28 WebElement exampleDiv = navigateToExample("Demo-ImageField-Example1");
29 WebElement field = findElement(By.cssSelector("div[data-label='ImageField 1']"), exampleDiv);
30
31 String fieldId = field.getAttribute("id");
32
33 assertIsVisible("#" + fieldId);
34 assertIsVisible("label[data-label_for='" + fieldId + "']");
35 WebElement label = findElement(By.cssSelector("label[data-label_for='" + fieldId + "']"), field);
36 if (!label.getText().contains("ImageField 1:")) {
37 fail("Label text does not match");
38 }
39
40 String imgId = label.getAttribute("for");
41
42 assertIsVisible("#" + imgId + "[src='/krad/images/pdf.png']");
43 assertIsVisible("#" + imgId + "[alt='']");
44
45
46 findElement(By.cssSelector("span[data-label_for='" + fieldId + "'] + img[src='/krad/images/pdf.png']"),
47 exampleDiv);
48 }
49
50 protected void testImageFieldAlternateText() throws Exception {
51 WebElement exampleDiv = navigateToExample("Demo-ImageField-Example2");
52 WebElement field = findElement(By.cssSelector("div[data-label='ImageField 1']"), exampleDiv);
53
54 String fieldId = field.getAttribute("id");
55
56 WebElement label = findElement(By.cssSelector("label[data-label_for='" + fieldId + "']"), field);
57
58 String imgId = label.getAttribute("for");
59
60 assertIsVisible("#" + imgId + "[src='/krad/images/pdf_ne.png']");
61 assertIsVisible("#" + imgId + "[alt='pdf']");
62 }
63
64 protected void testImageFieldExamples() throws Exception {
65 testImageFieldDefault();
66 testImageFieldAlternateText();
67 }
68
69 @Test
70 public void testImageFieldExamplesBookmark() throws Exception {
71 testImageFieldExamples();
72 passed();
73 }
74
75 @Test
76 public void testImageFieldExamplesNav() throws Exception {
77 testImageFieldExamples();
78 passed();
79 }
80
81 @Test
82 public void testImageFieldDefaultBookmark() throws Exception {
83 testImageFieldDefault();
84 passed();
85 }
86
87 @Test
88 public void testImageFieldDefaultNav() throws Exception {
89 testImageFieldDefault();
90 passed();
91 }
92
93 @Test
94 public void testImageFieldAlternateTextBookmark() throws Exception {
95 testImageFieldAlternateText();
96 passed();
97 }
98
99 @Test
100 public void testImageFieldAlternateTextNav() throws Exception {
101 testImageFieldAlternateText();
102 passed();
103 }
104 }