1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package edu.samplu.krad.demo.uif.library.fields;
18
19 import edu.samplu.common.Failable;
20 import edu.samplu.common.ITUtil;
21 import edu.samplu.krad.demo.uif.library.DemoLibraryITBase;
22 import org.kuali.rice.krad.uif.UifConstants;
23 import org.openqa.selenium.By;
24 import org.openqa.selenium.WebElement;
25
26
27
28
29 public abstract class DemoLibraryDataFieldSmokeTestBase extends DemoLibraryITBase {
30
31
32
33 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-DataField-View";
34
35 @Override
36 public String getTestUrl() {
37 return ITUtil.KRAD_PORTAL;
38 }
39
40 protected void testDataFieldDefault() throws Exception {
41 WebElement exampleDiv = navigateToExample("Demo-DataField-Example1");
42 WebElement field = exampleDiv.findElement(By.cssSelector("div[data-label='DataField 1']"));
43
44 String fieldId = field.getAttribute("id");
45 String controlId = fieldId + UifConstants.IdSuffixes.CONTROL;
46
47 assertIsVisible("#" + fieldId);
48 assertIsVisible("label[for='" + controlId + "']");
49
50 WebElement label = field.findElement(By.cssSelector("label[for='" + controlId + "']"));
51 if(!label.getText().contains("DataField 1:")){
52 fail("Label text does not match");
53 }
54
55 assertIsVisible("#" + controlId);
56
57 assertTextPresent("1001", "#" + controlId, "DataField value not correct");
58 }
59
60 protected void testDataFieldLabelTop() throws Exception {
61 WebElement exampleDiv = navigateToExample("Demo-DataField-Example2");
62 WebElement field = exampleDiv.findElement(By.cssSelector("div[data-label='DataField 1']"));
63
64 String fieldId = field.getAttribute("id");
65 String controlId = fieldId + UifConstants.IdSuffixes.CONTROL;
66
67 assertIsVisible("#" + fieldId);
68 assertIsVisible("label[for='" + controlId + "']");
69
70 WebElement label = field.findElement(By.cssSelector("label[for='" + controlId + "']"));
71 if(!label.getText().contains("DataField 1:")){
72 fail("Label text does not match");
73 }
74
75 WebElement labelspan = field.findElement(By.cssSelector("span[data-label_for='" + fieldId + "']"));
76 if(!labelspan.getAttribute("class").contains("uif-labelBlock")){
77 fail("Label span does not contain the appropriate class expected");
78 }
79
80 assertIsVisible("#" + controlId);
81 }
82
83 protected void testDataFieldExamples() throws Exception{
84 testDataFieldDefault();
85 testDataFieldLabelTop();
86 }
87
88 public void testDataFieldNav(Failable failable) throws Exception{
89 navigateToLibraryDemo("Fields", "Data Field");
90 testDataFieldExamples();
91 passed();
92 }
93
94 public void testDataFieldBookmark(Failable failable) throws Exception{
95 testDataFieldExamples();
96 passed();
97 }
98 }