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