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 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 jiraAwareWaitFor(By.xpath(SECOND_BREADCRUMB_NAV_XPATH));
57 assertFalse(isVisibleByXpath(SECOND_BREADCRUMB_NAV_XPATH));
58
59 waitAndClickByXpath(getTriangleXpath(), "failed on breadcrumb pageNumber " + pageNumber);
60 Thread.sleep(100);
61 assertTrue(isVisibleByXpath(SECOND_BREADCRUMB_NAV_XPATH));
62 waitAndClickByXpath(getTriangleXpath());
63 assertFalse(isVisibleByXpath(SECOND_BREADCRUMB_NAV_XPATH));
64 waitAndClickByXpath(getTriangleXpath());
65
66
67
68 waitAndClickByXpath(SECOND_BREADCRUMB_NAV_XPATH +"/li[" + pageNumber + "]/a");
69 waitForElementPresentById("TopLink" + pageNumber, "Breadcrumb number " + pageNumber + " failure", 30);
70 driver.getCurrentUrl().contains("pageId=UifCompView-Page" + pageNumber);
71 }
72
73 protected void testBreadcrumbs() throws Exception {
74 for (int i = 0, s = breadcrumbOrderIndexes.length; i < s; i++) {
75 testBreadcrumb(breadcrumbOrderIndexes[i]);
76 }
77 }
78
79 protected void testBreadcrumbsShuffled() throws Exception {
80 int[] copiedBreadcrumbOrderIndex = Arrays.copyOf(breadcrumbOrderIndexes, breadcrumbOrderIndexes.length);
81
82 Collections.shuffle(Arrays.asList(copiedBreadcrumbOrderIndex));
83 for (int i = 0, s = copiedBreadcrumbOrderIndex.length; i < s; i++) {
84 jGrowl("Click on Bread crumb index number " + i);
85 testBreadcrumb(copiedBreadcrumbOrderIndex[i]);
86 }
87 }
88
89 @Test
90 public void testBreadcrumbBookmark() throws Exception {
91 testBreadcrumbs();
92 passed();
93 }
94
95 @Test
96 public void testBreadcrumbShuffledBookmark() throws Exception {
97 testBreadcrumbsShuffled();
98 passed();
99 }
100
101 @Test
102 public void testBreadcrumbNav() throws Exception {
103 testBreadcrumbs();
104 passed();
105 }
106
107 @Test
108 public void testBreadcrumbShuffledNav() throws Exception {
109 testBreadcrumbsShuffled();
110 passed();
111 }
112 }