1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.testtools.selenium.breadcrumb;
17
18 import org.junit.Test;
19 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
20
21 import java.util.Arrays;
22 import java.util.Collections;
23
24
25
26
27 public abstract class BreadcrumbAftBase extends WebDriverLegacyITBase {
28
29
30
31
32 public static final String SECOND_BREADCRUMB_NAV_XPATH = "//div[@class='uif-breadcrumbSiblingContent']//div[@class='uif-inputField']//ul[@class='uif-optionList']";
33
34
35
36
37
38 public static final String SECOND_DOWN_TRIANGLE_XPATH = "(//a[@class='uif-breadcrumbSiblingLink'])[2]";
39
40 String[][] selectAsserts = {{"UifCompView", "Uif Components"}};
41
42 int[] breadcrumbOrderIndexes = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1};
43
44 protected String getTriangleXpath() {
45 return SECOND_DOWN_TRIANGLE_XPATH;
46 }
47
48 protected void testBreadcrumb(int pageNumber) throws Exception {
49
50
51
52
53
54
55
56 assertFalse(isVisibleByXpath(SECOND_BREADCRUMB_NAV_XPATH));
57
58 waitAndClickByXpath(getTriangleXpath(), "failed on breadcrumb pageNumber " + pageNumber);
59 Thread.sleep(100);
60 assertTrue(isVisibleByXpath(SECOND_BREADCRUMB_NAV_XPATH));
61 waitAndClickByXpath(getTriangleXpath());
62 assertFalse(isVisibleByXpath(SECOND_BREADCRUMB_NAV_XPATH));
63 waitAndClickByXpath(getTriangleXpath());
64
65
66
67 waitAndClickByXpath(SECOND_BREADCRUMB_NAV_XPATH +"/li[" + pageNumber + "]/a");
68 waitForElementPresentById("TopLink" + pageNumber, "Breadcrumb number " + pageNumber + " failure", 30);
69 driver.getCurrentUrl().contains("pageId=UifCompView-Page" + pageNumber);
70 }
71
72 protected void testBreadcrumbs() throws Exception {
73 for (int i = 0, s = breadcrumbOrderIndexes.length; i < s; i++) {
74 testBreadcrumb(breadcrumbOrderIndexes[i]);
75 }
76 }
77
78 protected void testBreadcrumbsShuffled() throws Exception {
79 int[] copiedBreadcrumbOrderIndex = Arrays.copyOf(breadcrumbOrderIndexes, breadcrumbOrderIndexes.length);
80
81 Collections.shuffle(Arrays.asList(copiedBreadcrumbOrderIndex));
82 for (int i = 0, s = copiedBreadcrumbOrderIndex.length; i < s; i++) {
83 testBreadcrumb(copiedBreadcrumbOrderIndex[i]);
84 }
85 }
86
87 @Test
88 public void testBreadcrumbBookmark() throws Exception {
89 testBreadcrumbs();
90 passed();
91 }
92
93 @Test
94 public void testBreadcrumbShuffledBookmark() throws Exception {
95 testBreadcrumbsShuffled();
96 passed();
97 }
98
99 @Test
100 public void testBreadcrumbNav() throws Exception {
101 testBreadcrumbs();
102 passed();
103 }
104
105 @Test
106 public void testBreadcrumbShuffledNav() throws Exception {
107 testBreadcrumbsShuffled();
108 passed();
109 }
110 }