forked from BugorDmitriy/OpenWeatherJavaProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTopMenuTest.java
More file actions
383 lines (280 loc) · 13.3 KB
/
Copy pathTopMenuTest.java
File metadata and controls
383 lines (280 loc) · 13.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
package tests;
import base.BaseTest;
import org.testng.Assert;
import org.testng.annotations.Test;
import pages.MainPage;
import pages.OurInitiativesPage;
import pages.TestData;
import pages.home.HomeMarketplacePage;
import pages.home.HomeUsersSignInPage;
import pages.top_menu.*;
import utils.ProjectConstants;
import java.util.List;
public class TopMenuTest extends BaseTest {
@Test
public void testAPIMenuNavigatesToAPIPage() {
final String expectedURL = "https://openweathermap.org/api";
final String expectedTitle = "Weather API - OpenWeatherMap";
final String oldURL = openBaseURL().getCurrentURL();
String actualURL = new MainPage(getDriver())
.clickAPIMenu()
.getCurrentURL();
String actualTitle = new APIPage(getDriver()).getTitle();
Assert.assertNotEquals(actualURL, oldURL);
Assert.assertEquals(actualURL, expectedURL);
Assert.assertEquals(actualTitle, expectedTitle);
}
@Test
public void testMarketplaceMenuNavigatesToMarketplacePage() {
final String expectedURL = "https://home.openweathermap.org/marketplace";
final String expectedTitle = "Marketplace: History Bulk, History Forecast Bulk, "
+ "Historical Weather Data by State for all ZIP codes, USA - OpenWeather";
final String oldURL = openBaseURL().getCurrentURL();
MainPage mainPage = new MainPage(getDriver());
HomeMarketplacePage homeMarketplacePage = mainPage
.clickMarketplaceMenu()
.switchToMarketplaceWindow();
String actualURL = homeMarketplacePage
.getCurrentURL();
String actualTitle = homeMarketplacePage.getTitle();
Assert.assertNotEquals(actualURL, oldURL);
Assert.assertEquals(actualURL, expectedURL);
Assert.assertEquals(actualTitle, expectedTitle);
}
@Test
public void testGuideMenuNavigatesToGuidePage() {
final String expectedURL = "https://openweathermap.org/guide";
final String expectedTitle = "OpenWeatherMap API guide - OpenWeatherMap";
final String oldURL = openBaseURL().getCurrentURL();
String actualURL = new MainPage(getDriver())
.clickGuideMenu()
.getCurrentURL();
String actualTitle = new GuidePage(getDriver()).getTitle();
Assert.assertNotEquals(actualURL, oldURL);
Assert.assertEquals(actualURL, expectedURL);
Assert.assertEquals(actualTitle, expectedTitle);
}
@Test
public void testMapsMenuNavigatesToWeatherMapsPage() {
final String expectedURL = "https://openweathermap.org/weathermap";
final String expectedTitle = "Interactive weather maps - OpenWeatherMap";
final String oldURL = openBaseURL().getCurrentURL();
String actualURL = new MainPage(getDriver())
.clickMapsMenu()
.getFormattedURL();
String actualTitle = new WeatherMapsPage(getDriver()).getTitle();
Assert.assertNotEquals(actualURL, oldURL);
Assert.assertEquals(actualURL, expectedURL);
Assert.assertEquals(actualTitle, expectedTitle);
}
@Test
public void testHowToStartMenuNavigatesToHowToStartPage() {
final String expectedURL = "https://openweathermap.org/appid";
final String expectedTitle = "How to start to work with Openweather API - OpenWeatherMap";
final String oldURL = openBaseURL().getCurrentURL();
String actualURL = new MainPage(getDriver())
.clickSupportMenu()
.clickHowToStartSupportSubmenu()
.getCurrentURL();
String actualTitle = new HowToStartPage(getDriver()).getTitle();
Assert.assertNotEquals(actualURL, oldURL);
Assert.assertEquals(actualURL, expectedURL);
Assert.assertEquals(actualTitle, expectedTitle);
}
@Test
public void testPlaceholderIsAvailable_TopMenu() {
final String expectedInnerTextOfPlaceholder = "Weather in your city";
final String attribute = "placeholder";
MainPage mainPage = openBaseURL();
Assert.assertTrue(mainPage.isPlaceholderDisplayed());
String actualInnerTextOfPlaceholder = mainPage.getInnerTextOfPlaceholder(attribute);
Assert.assertEquals(actualInnerTextOfPlaceholder, expectedInnerTextOfPlaceholder);
}
@Test
public void testOurInitiativesMenuNavigatesToOurInitiativesPage() {
final String expectedURL = "https://openweathermap.org/our-initiatives";
final String expectedTitle = "Our Initiatives - OpenWeatherMap";
final String oldURL = openBaseURL().getCurrentURL();
String actualURL = new MainPage(getDriver())
.clickOurInitiativesMenu()
.getCurrentURL();
String actualTitle = new OurInitiativesPage(getDriver()).getTitle();
Assert.assertNotEquals(actualURL, oldURL);
Assert.assertEquals(actualURL, expectedURL);
Assert.assertEquals(actualTitle, expectedTitle);
}
@Test
public void testSupportMenuLinksTexts() {
final List<String> expectedList = List.of(
"FAQ",
"How to start",
"Ask a question"
);
List<String> actualList =
openBaseURL()
.clickSupportMenu()
.getLinksText();
Assert.assertEquals(actualList, expectedList);
}
@Test
public void testSupportMenuIsClickable() {
final String expectedIfVisible = "dropdown-menu dropdown-visible";
final String expectedIfNotVisible = "dropdown-menu";
openBaseURL();
String actualIfVisible = new MainPage(getDriver())
.clickSupportMenu()
.getSupportMenuIsActiveValue();
Assert.assertTrue(new MainPage(getDriver()).isSupportDropdownContainerDisplayed());
Assert.assertEquals(actualIfVisible, expectedIfVisible);
String actualIfNotVisible = new MainPage(getDriver())
.clickSupportMenu()
.getSupportMenuIsActiveValue();
Assert.assertEquals(actualIfNotVisible, expectedIfNotVisible);
}
@Test
public void testPartnersMenuNavigatesToPartnersPage() {
final String expectedURL = "https://openweathermap.org/examples";
final String expectedTitle = "Partners and solutions - OpenWeatherMap";
final String oldURL = openBaseURL().getCurrentURL();
String actualURL = new MainPage(getDriver())
.clickPartnersMenu()
.getCurrentURL();
String actualTitle = new PartnersPage(getDriver()).getTitle();
Assert.assertNotEquals(actualURL, oldURL);
Assert.assertEquals(actualURL, expectedURL);
Assert.assertEquals(actualTitle, expectedTitle);
}
@Test
public void testTopMenuLinkAmount() {
final int expectedTopMenuLinkAmount = 12;
int actualTopMenuLinkAmount =
openBaseURL()
.topMenuLinkAmount();
Assert.assertEquals(actualTopMenuLinkAmount, expectedTopMenuLinkAmount);
}
@Test
public void testCompanyLogoNavigatesToBaseURL() {
final String expectedURL = "https://openweathermap.org/";
final String expectedTitle = "Сurrent weather and forecast - OpenWeatherMap";
openBaseURL();
String actualURL = new MainPage(getDriver())
.clickLogo()
.getCurrentURL();
String actualTitle = new MainPage(getDriver()).getTitle();
Assert.assertEquals(actualURL, expectedURL);
Assert.assertEquals(actualTitle, expectedTitle);
}
@Test
public void testFAQSupportSubmenuNavigatesToFAQPage() {
final String expectedURL = "https://openweathermap.org/faq";
final String expectedTitle = "Frequently Asked Questions - OpenWeatherMap";
final String oldURL = openBaseURL().getCurrentURL();
String actualURL = new MainPage(getDriver())
.clickSupportMenu()
.clickFAQSupportSubmenu()
.getCurrentURL();
String actualTitle = new FAQPage(getDriver()).getTitle();
Assert.assertNotEquals(actualURL, oldURL);
Assert.assertEquals(actualURL, expectedURL);
Assert.assertEquals(actualTitle, expectedTitle);
}
@Test
public void testDashboardMenuNavigatesToDashboardPage() {
final String expectedURL = "https://openweathermap.org/weather-dashboard";
final String expectedTitle = "Weather dashboard - OpenWeatherMap";
final String oldURL = openBaseURL().getCurrentURL();
String actualURL = new MainPage(getDriver())
.clickDashboardMenu()
.getCurrentURL();
String actualTitle = new WeatherDashboardPage(getDriver()).getTitle();
Assert.assertNotEquals(actualURL, oldURL);
Assert.assertEquals(actualURL, expectedURL);
Assert.assertEquals(actualTitle, expectedTitle);
}
@Test
public void testPricingMenuNavigatesToPricePage() {
final String expectedURL = "https://openweathermap.org/price";
final String expectedTitle = "Pricing - OpenWeatherMap";
final String oldURL = openBaseURL().getCurrentURL();
String actualURL = new MainPage(getDriver())
.clickPricingMenu()
.getCurrentURL();
String actualTitle = new PricePage(getDriver()).getTitle();
Assert.assertNotEquals(actualURL, oldURL);
Assert.assertEquals(actualURL, expectedURL);
Assert.assertEquals(actualTitle, expectedTitle);
}
@Test(dataProvider = "TopMenuTestData", dataProviderClass = TestData.class)
public void testEachTopMenuNavigatesToCorrespondingPage(
int index, String menuName, String href, String expectedURL, String expectedTitle) {
MainPage mainPage = openBaseURL();
String oldURL = mainPage.getCurrentURL();
String oldTitle = mainPage.getTitle();
mainPage.clickTopMenu(index);
String actualURL = getDriver().getCurrentUrl();
String actualTitle = getDriver().getTitle();
if (index != 0) {
Assert.assertNotEquals(actualURL, oldURL);
Assert.assertNotEquals(actualTitle, oldTitle);
}
if (index != 6) {
Assert.assertEquals(actualURL, expectedURL);
} else {
Assert.assertTrue(actualURL.contains(expectedURL));
}
Assert.assertEquals(actualTitle, expectedTitle);
}
@Test
public void testHamburgerMenuIsAvailableAndHasOptions_TopMenu() {
final int expectedNumberOfOptionsHamburgerMenu = 12;
final List<String> expectedHamburgerMenuList = List.of(
"Guide", "API", "Dashboard", "Marketplace", "Pricing",
"Maps", "Our Initiatives", "Partners", "Blog", "For Business",
"Ask a question", "Sign in"
);
openBaseURL()
.setWindowWithHamburgerMenu(ProjectConstants.WIDTH_HAMBURGER_MENU, ProjectConstants.HEIGHT_HAMBURGER_MENU)
.clickHamburgerMenuIcon();
int actualNumberOfOptionsHamburgerMenu = new MainPage(getDriver()).getNumberOfOptionsHamburgerMenu();
List<String> actualHamburgerMenuList = new MainPage(getDriver()).getHamburgerMenuList();
Assert.assertTrue(new MainPage(getDriver()).isHamburgerIconDisplayed());
Assert.assertTrue(new MainPage(getDriver()).getNumberOfOptionsHamburgerMenu() > 0);
Assert.assertEquals(actualNumberOfOptionsHamburgerMenu, expectedNumberOfOptionsHamburgerMenu);
Assert.assertEquals(actualHamburgerMenuList, expectedHamburgerMenuList);
}
@Test
public void testHamburgerMenuHasLogo() {
final String expectedURL = "https://openweathermap.org/";
openBaseURL();
String actualURL = new MainPage(getDriver())
.setWindowWithHamburgerMenu(ProjectConstants.WIDTH_HAMBURGER_MENU, ProjectConstants.HEIGHT_HAMBURGER_MENU)
.clickLogo().getCurrentURL();
Assert.assertTrue(new MainPage(getDriver()).isLogoIconDisplayed());
Assert.assertEquals(actualURL, expectedURL);
}
@Test
public void testNavigationBarSearchField_NavigatesToFindPage() {
final String expectedURL = "https://openweathermap.org/find?q=Barcelona";
final String expectedName = "Barcelona";
final String oldURL = openBaseURL().getCurrentURL();
String actualURL = new MainPage(getDriver())
.clickSearchFieldTopMenu()
.inputSearchCriteriaAndEnter(expectedName)
.getCurrentURL();
Assert.assertNotEquals(oldURL, actualURL);
Assert.assertEquals(actualURL, expectedURL);
}
@Test
public void testSignInMenuNavigatesToSignInPage() {
final String expectedURL = "https://home.openweathermap.org/users/sign_in";
final String expectedWelcomeMessage = "Sign In To Your Account";
final String oldURL = openBaseURL().getCurrentURL();
String actualURL = new MainPage(getDriver())
.clickSignInMenu()
.getCurrentURL();
String actualWelcomeMessage = new HomeUsersSignInPage(getDriver()).getWelcomeMessage();
Assert.assertNotEquals(actualURL, oldURL);
Assert.assertEquals(actualURL, expectedURL);
Assert.assertEquals(actualWelcomeMessage, expectedWelcomeMessage);
}
}