1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.samplu.krad.compview;
17
18 import com.thoughtworks.selenium.SeleneseTestBase;
19 import edu.samplu.common.SmokeTestBase;
20 import org.junit.Test;
21
22 import java.util.Arrays;
23 import java.util.Collections;
24
25
26
27
28 public class BreadcrumbSmokeTest extends SmokeTestBase {
29
30
31
32
33 public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&pageId=UifCompView-Page1";
34
35
36
37
38 public static final String SECOND_BREADCRUMB_NAV_XPATH = "//div[@class='uif-breadcrumbSiblingContent']//div[@class='uif-inputField']//ul[@class='uif-optionList']";
39
40
41
42
43
44 public static final String SECOND_DOWN_TRIANGLE_XPATH = "(//a[@class='uif-breadcrumbSiblingLink'])[2]";
45
46 String[][] selectAsserts = {{"UifCompView", "Uif Components"}};
47
48 int[] breadcrumbOrderIndexes = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1};
49
50 @Override
51 protected String getBookmarkUrl() {
52 return BOOKMARK_URL;
53 }
54
55 protected String getTriangleXpath() {
56 return SECOND_DOWN_TRIANGLE_XPATH;
57 }
58
59 protected void navigate() throws Exception {
60 waitAndClickKRAD();
61 waitAndClickByXpath(KITCHEN_SINK_XPATH);
62 switchToWindow(KUALI_UIF_COMPONENTS_WINDOW_XPATH);
63 }
64
65 protected void testBreadcrumb(int pageNumber) throws Exception {
66
67
68
69
70
71
72
73 SeleneseTestBase.assertFalse(isVisibleByXpath(SECOND_BREADCRUMB_NAV_XPATH));
74
75 waitAndClickByXpath(getTriangleXpath());
76 Thread.sleep(100);
77 SeleneseTestBase.assertTrue(isVisibleByXpath(SECOND_BREADCRUMB_NAV_XPATH));
78 waitAndClickByXpath(getTriangleXpath());
79 SeleneseTestBase.assertFalse(isVisibleByXpath(SECOND_BREADCRUMB_NAV_XPATH));
80 waitAndClickByXpath(getTriangleXpath());
81
82
83
84 waitAndClickByXpath(SECOND_BREADCRUMB_NAV_XPATH +"/li[" + pageNumber + "]/a");
85 waitForElementPresentById("TopLink" + pageNumber);
86 driver.getCurrentUrl().contains("pageId=UifCompView-Page" + pageNumber);
87 }
88
89 protected void testBreadcrumbs() throws Exception {
90 for (int i = 0, s = breadcrumbOrderIndexes.length; i < s; i++) {
91 testBreadcrumb(breadcrumbOrderIndexes[i]);
92 }
93 }
94
95 protected void testBreadcrumbsShuffled() throws Exception {
96 int[] copiedBreadcrumbOrderIndex = Arrays.copyOf(breadcrumbOrderIndexes, breadcrumbOrderIndexes.length);
97
98 Collections.shuffle(Arrays.asList(copiedBreadcrumbOrderIndex));
99 for (int i = 0, s = copiedBreadcrumbOrderIndex.length; i < s; i++) {
100 testBreadcrumb(copiedBreadcrumbOrderIndex[i]);
101 }
102 }
103
104 @Test
105 public void testBreadcrumbBookmark() throws Exception {
106 testBreadcrumbs();
107 passed();
108 }
109
110 @Test
111 public void testBreadcrumbShuffledBookmark() throws Exception {
112 testBreadcrumbsShuffled();
113 passed();
114 }
115
116 @Test
117 public void testBreadcrumbNav() throws Exception {
118 testBreadcrumbs();
119 passed();
120 }
121
122 @Test
123 public void testBreadcrumbShuffledNav() throws Exception {
124 testBreadcrumbsShuffled();
125 passed();
126 }
127 }