forked from BugorDmitriy/OpenWeatherJavaProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWidgetsTest.java
More file actions
104 lines (78 loc) · 3.46 KB
/
Copy pathWidgetsTest.java
File metadata and controls
104 lines (78 loc) · 3.46 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
package tests;
import base.BaseTest;
import org.testng.Assert;
import org.testng.Reporter;
import org.testng.annotations.Test;
import pages.footer_menu.WidgetsPage;
import utils.ProjectConstants;
import java.util.List;
public class WidgetsTest extends BaseTest {
@Test
public void testSelectYourCityFieldContainsChosenCity() throws InterruptedException {
final String city = "Rome";
WidgetsPage widgetPage = openBaseURL()
.scrollToFooterMenu()
.clickWidgetsPageFooterMenu();
sleep(1000);
final String oldCity = widgetPage.getCityName();
final String newCity = widgetPage
.inputYourAPIKey(ProjectConstants.WIDGETS_KEY)
.inputYourCityName(city)
.clickSearchCityButton()
.waitCityFromSelectCityToBeChanged(oldCity)
.getCityName();
Reporter.log("City changed to ------" + newCity, true);
Assert.assertNotEquals(newCity, oldCity);
List<String> actualCitiesTexts = widgetPage.getSelectedCityTexts();
Reporter.log("Actual list of cities is -------" + actualCitiesTexts, true);
for (String actualCity : actualCitiesTexts) {
Assert.assertTrue(actualCity.contains(city));
}
}
@Test
public void testErrorMessage_WhenEnteringInvalidAPIKeyInWidgetForm() {
final String apiKey = "6a7ee29a7bc59ae512514cf9d4e49";
final String expectedErrorMessage = "Validation error";
final String cityName = "Athens";
WidgetsPage widgetPage = openBaseURL()
.scrollToFooterMenu()
.clickWidgetsPageFooterMenu();
final String oldCity = widgetPage.getCityName();
Reporter.log("Old city was --------" + oldCity, true);
final String newCity = widgetPage
.inputYourAPIKey(apiKey)
.inputYourCityName(cityName)
.clickSearchCityButton()
.waitCityFromSelectCityToBeChanged(oldCity)
.getCityName();
Reporter.log("City changed to ------" + newCity, true);
String actualErrorMessage = widgetPage.getErrorMessage();
Assert.assertEquals(actualErrorMessage, expectedErrorMessage);
}
@Test
public void testAllWidgetsDisplayChosenCity() throws InterruptedException {
final String key = "20cbbe5f82ae947874eb39f29f8ffbe1";
final String cityCountry = "Rome, US";
WidgetsPage widgetPage = openBaseURL()
.scrollToFooterMenu()
.clickWidgetsPageFooterMenu();
sleep(1000);
final String oldCity = widgetPage
.waitForBiggerWidgetToAppear()
.getCityNameWidget();
Reporter.log("Old city was --------" + oldCity, true);
final String newCity = widgetPage.inputYourAPIKey(key)
.inputYourCityName(cityCountry)
.clickSearchCityButton()
.waitCityToBeChanged(oldCity)
.getCityNameWidget();
Reporter.log("City changed to ------" + newCity, true);
Assert.assertNotEquals(newCity, oldCity);
List<String> allWidgetsTexts = widgetPage.getAllWidgetsCityName();
Reporter.log("The size of the allWidgetsTexts is "
+ allWidgetsTexts.size() + "\nList of widget's cities ----- " + allWidgetsTexts, true);
for (String cityName : allWidgetsTexts) {
Assert.assertEquals(cityName, cityCountry);
}
}
}