1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.samplu.travel.krad.test;
17
18 import edu.samplu.common.Failable;
19 import edu.samplu.common.ITUtil;
20 import edu.samplu.common.WebDriverLegacyITBase;
21
22 import org.junit.Assert;
23 import org.openqa.selenium.Alert;
24 import org.openqa.selenium.By;
25 import org.openqa.selenium.WebElement;
26
27 import com.thoughtworks.selenium.SeleneseTestBase;
28
29
30
31
32
33
34 public abstract class InquiryAbstractSmokeTestBase extends WebDriverLegacyITBase {
35
36
37
38
39
40
41
42 public static final String BOOKMARK_URL = ITUtil.PORTAL
43 + "?channelTitle=Travel%20Account%20Lookup&channelUrl="
44 + ITUtil.getBaseUrlString() + ITUtil.KRAD_LOOKUP_METHOD
45 + "edu.sampleu.travel.bo.TravelAccount"
46 + "&returnLocation=" + ITUtil.PORTAL_URL + ITUtil.HIDE_RETURN_LINK + ITUtil.SHOW_MAINTENANCE_LINKS;
47
48
49
50
51 public static final String SEARCH_BUTTON_XPATH ="//div[contains(button, 'Search')]/button[3]";
52
53
54
55
56 public static final String CRITERIA_NAME="lookupCriteria";
57
58
59
60
61 public static final String FANCYBOX_IFRAME_XPATH="//iframe[@class='fancybox-iframe']";
62
63
64
65
66
67
68 @Override
69 public String getTestUrl() {
70 return ITUtil.PORTAL;
71 }
72
73 protected void navigation() throws Exception {
74 waitAndClickKRAD();
75
76 waitAndClickByXpath("(//a[contains(text(),'Travel Account Lookup')])[3]");
77 }
78
79 protected void testInquiryNav(Failable failable) throws Exception {
80 navigation();
81 testInquiry();
82 passed();
83 }
84
85 protected void testInquiryBookmark(Failable failable) throws Exception {
86 testInquiry();
87 passed();
88 }
89
90 protected void testInquiry() throws Exception {
91 selectFrameIframePortlet();
92 waitAndTypeByName(CRITERIA_NAME+"[number]", "a1");
93 waitAndClickByXpath("//*[@alt='Direct Inquiry']");
94 selectTopFrame();
95 Thread.sleep(5000);
96 WebElement iframe1 = driver.findElement(By.xpath(FANCYBOX_IFRAME_XPATH));
97 driver.switchTo().frame(iframe1);
98 SeleneseTestBase.assertEquals("Travel Account Inquiry", getTextByXpath("//h1/span").trim());
99 assertElementPresentByLinkText("a1");
100 selectTopFrame();
101 waitAndClickByXpath("//div[@class='fancybox-item fancybox-close']");
102 selectFrameIframePortlet();
103 waitAndClickByXpath("//button[contains(text(),'Clear Values')]");
104
105
106 Thread.sleep(2000);
107 waitAndClickByXpath("//*[@alt='Direct Inquiry']");
108 Alert a1 = driver.switchTo().alert();
109 Assert.assertEquals("Please enter a value in the appropriate field.", a1.getText());
110 a1.accept();
111 switchToWindow("null");
112 selectFrameIframePortlet();
113
114
115 waitAndTypeByName(CRITERIA_NAME+"[foId]", "1");
116 waitAndClickByXpath("//*[@id='u229']");
117 selectTopFrame();
118 Thread.sleep(5000);
119 WebElement iframe2 = driver.findElement(By.xpath(FANCYBOX_IFRAME_XPATH));
120 driver.switchTo().frame(iframe2);
121 Assert.assertEquals("Fiscal Officer Lookup", getTextByXpath("//h1/span").trim());
122 Assert.assertEquals("1", getAttributeByName(CRITERIA_NAME+"[id]", "value"));
123 waitAndClickByXpath(SEARCH_BUTTON_XPATH);
124 selectFrameIframePortlet();
125 selectOptionByName(CRITERIA_NAME+"[extension.accountTypeCode]", "CAT");
126 waitAndClickByXpath("//fieldset[@id='u232_fieldset']/input[@alt='Search Field']");
127 selectTopFrame();
128 Thread.sleep(5000);
129 WebElement iframe3 = driver.findElement(By.xpath(FANCYBOX_IFRAME_XPATH));
130 driver.switchTo().frame(iframe3);
131 Assert.assertEquals("Travel Account Type Lookup", getTextByXpath("//h1/span").trim());
132 Assert.assertEquals("CAT", getAttributeByName(CRITERIA_NAME+"[accountTypeCode]", "value"));
133 waitAndClickByXpath(SEARCH_BUTTON_XPATH);
134 selectFrameIframePortlet();
135 }
136 }