1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.demo.uif.library.collections;
17
18 import org.junit.Test;
19 import org.kuali.rice.krad.demo.uif.library.DemoLibraryBase;
20 import org.openqa.selenium.By;
21 import org.openqa.selenium.WebElement;
22
23 import java.util.List;
24
25
26
27
28 public class DemoCollectionSequenceAft extends DemoLibraryBase {
29
30
31
32
33 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-CollectionSequenceView";
34
35 @Override
36 protected String getBookmarkUrl() {
37 return BOOKMARK_URL;
38 }
39
40 @Override
41 protected void navigate() throws Exception {
42 navigateToLibraryDemo("Collection Features", "Sequence Column");
43 }
44
45 protected void changeSequenceView() throws Exception {
46
47
48 assert(isOptionSelected("exampleShown", "Demo-CollectionSequence-Example1"));
49 testAutoSequence();
50
51
52 selectOptionByName("exampleShown","Demo-CollectionSequence-Example2");
53 waitForPageToLoad();
54 assert(isOptionSelected("exampleShown", "Demo-CollectionSequence-Example2"));
55 testFieldSequence();
56
57
58 selectOptionByName("exampleShown","Demo-CollectionSequence-Example3");
59 waitForPageToLoad();
60 assert(isOptionSelected("exampleShown", "Demo-CollectionSequence-Example3"));
61 testNoSequence();
62 }
63
64 protected void testCollectionSequenceExamples() throws Exception {
65 changeSequenceView();
66 }
67
68 private boolean isOptionSelected(String dropDownName, String optionValue) {
69 WebElement select = driver.findElement(By.name(dropDownName));
70 List<WebElement> options = select.findElements(By.tagName("option"));
71 for (WebElement option: options) {
72 if (option.getAttribute("selected")!=null) {
73 return true;
74 }
75 }
76 return false;
77 }
78
79 private void testAutoSequence() throws InterruptedException{
80 for(short i=1; i<10 ; i++)
81 {
82 if(i==2)
83 i++;
84 waitForElementPresentByXpath("//div[@data-parent='Demo-CollectionSequence-Example1']/div[@class='uif-disclosureContent']/div/table/tbody/tr/td/div/span[contains(text(),'"+i+"')]");
85 }
86 }
87
88 private void testFieldSequence() throws InterruptedException{
89
90 waitForElementPresentByXpath("//div[@data-parent='Demo-CollectionSequence-Example2']/div[@class='uif-disclosureContent']/div/table/tbody/tr/td/div/span[contains(text(),'3')]");
91 }
92
93 private void testNoSequence() throws InterruptedException{
94 waitForElementNotPresent(By.xpath("//div[@data-parent='Demo-CollectionSequence-Example3']/div[@class='uif-disclosureContent']/div/table/tbody/tr/td/div/span"));
95 }
96
97 @Test
98 public void testCollectionSequenceBookmark() throws Exception {
99 testCollectionSequenceExamples();
100 passed();
101 }
102
103 @Test
104 public void testCollectionSequenceNav() throws Exception {
105 testCollectionSequenceExamples();
106 passed();
107 }
108 }