1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.samplu.krad.labs.sessionPolicy;
17
18 import edu.samplu.common.ITUtil;
19 import edu.samplu.common.WebDriverLegacyITBase;
20 import edu.samplu.common.WebDriverUtil;
21 import org.testng.annotations.Parameters;
22 import org.testng.annotations.Test;
23
24
25
26
27 public class LabsSessionPolicyRedirectHomeSTNGGen extends WebDriverLegacyITBase {
28
29
30
31
32 public static final String AJAX_REQUEST_BUTTON_TEXT = "Ajax Request";
33
34
35
36
37 public static final String BOOKMARK_URL = "/kr-krad/sessionPolicy?viewId=Lab-SessionPolicy-RedirectHome";
38
39
40
41
42 public static final String KILL_SESSION_BUTTON_TEXT = "Kill Session";
43
44
45
46
47 public static final String KRAD_SAMPLE_APP_HOME_URL_PART = "KradSampleAppHome";
48
49
50
51
52 public static final String LOGIN_TEXT = "Login";
53
54
55
56
57 public static final String NON_AJAX_REQUEST_BUTTON_TEXT = "NonAjax Request";
58
59
60
61
62 public static final String SESSION_TIMEOUT_REDIRECT_TO_HOME_HEADER_TEXT = "Session Timeout - Redirect to Home";
63
64
65
66
67 public static final String UIF_HEADER_TEXT_CLASS_NAME = "uif-headerText";
68
69
70
71
72 public static final String USER_NAME_TEXT = "UserName:";
73
74 @Override
75 public String getTestUrl() {
76 return BOOKMARK_URL;
77 }
78
79 @Test(groups = { "all", "fast", "default", "bookmark" }, description = "testNonAjaxAjaxBookmark")
80 @Parameters( { "seleniumHost", "seleniumPort", "os", "browser", "version", "webSite" })
81 public void testNonAjaxAjaxBookmark() throws Exception {
82 assertHeaderTextRedirectHome();
83
84 waitAndClickButtonByText(AJAX_REQUEST_BUTTON_TEXT);
85 assertHeaderTextRedirectHome();
86
87 waitAndClickButtonByText(NON_AJAX_REQUEST_BUTTON_TEXT);
88 assertHeaderTextRedirectHome();
89
90 waitAndClickButtonByText(KILL_SESSION_BUTTON_TEXT);
91 waitAndClickButtonByText(NON_AJAX_REQUEST_BUTTON_TEXT);
92 assertHomeRedirect();
93
94 driver.navigate().to(ITUtil.getBaseUrlString() + BOOKMARK_URL);
95 assertHeaderTextRedirectHome();
96
97 waitAndClickButtonByText(KILL_SESSION_BUTTON_TEXT);
98 waitAndClickButtonByText(AJAX_REQUEST_BUTTON_TEXT);
99 assertHomeRedirect();
100
101 passed();
102 }
103
104 @Test(groups = { "all", "fast", "default", "bookmark" }, description = "testAjaxNonAjaxBookmark")
105 @Parameters( { "seleniumHost", "seleniumPort", "os", "browser", "version", "webSite" })
106 public void testAjaxNonAjaxBookmark() throws Exception {
107 assertHeaderTextRedirectHome();
108
109 waitAndClickButtonByText(NON_AJAX_REQUEST_BUTTON_TEXT);
110 assertHeaderTextRedirectHome();
111
112 waitAndClickButtonByText(AJAX_REQUEST_BUTTON_TEXT);
113 assertHeaderTextRedirectHome();
114
115 waitAndClickButtonByText(KILL_SESSION_BUTTON_TEXT);
116 waitAndClickButtonByText(AJAX_REQUEST_BUTTON_TEXT);
117 assertHomeRedirect();
118
119 driver.navigate().to(ITUtil.getBaseUrlString() + BOOKMARK_URL);
120 assertHeaderTextRedirectHome();
121
122 waitAndClickButtonByText(KILL_SESSION_BUTTON_TEXT);
123 waitAndClickButtonByText(NON_AJAX_REQUEST_BUTTON_TEXT);
124 assertHomeRedirect();
125
126 passed();
127 }
128
129 protected void assertHomeRedirect() throws InterruptedException {
130 waitForElementPresentByClassName(UIF_HEADER_TEXT_CLASS_NAME);
131 assertTextPresent(LOGIN_TEXT);
132 assertTextPresent(USER_NAME_TEXT);
133 WebDriverUtil.kradLogin(driver, user, this);
134 driver.getCurrentUrl().contains(KRAD_SAMPLE_APP_HOME_URL_PART);
135 }
136
137 protected void assertHeaderTextRedirectHome() throws InterruptedException {
138 waitForElementPresentByClassName(UIF_HEADER_TEXT_CLASS_NAME);
139 assertTextPresent(SESSION_TIMEOUT_REDIRECT_TO_HOME_HEADER_TEXT);
140 }
141 }