From 0a7b0ef388f01cba4f0912ca97839fb62b9e2046 Mon Sep 17 00:00:00 2001 From: Kofanskih Date: Wed, 19 Feb 2025 22:02:41 +0200 Subject: [PATCH 01/12] Add Main page, utils, first test, poms files --- pom.xml | 3 ++ ui-wheatherapi/pom.xml | 49 +++++++++++++++++++ .../com/wheatherapi/ui/pages/MainPage.java | 12 +++++ .../utils/ConfigurateBrowserSettings.java | 12 +++++ .../ui/tests/TodaysWeatherForecasTest.java | 25 ++++++++++ 5 files changed, 101 insertions(+) create mode 100644 ui-wheatherapi/pom.xml create mode 100644 ui-wheatherapi/src/main/java/com/wheatherapi/ui/pages/MainPage.java create mode 100644 ui-wheatherapi/src/main/java/utils/ConfigurateBrowserSettings.java create mode 100644 ui-wheatherapi/src/test/java/com/wheatherapi/ui/tests/TodaysWeatherForecasTest.java diff --git a/pom.xml b/pom.xml index aa23a3e..89b0ead 100644 --- a/pom.xml +++ b/pom.xml @@ -8,6 +8,9 @@ WheatherapiProject 1.0-SNAPSHOT pom + + ui-wheatherapi + 17 diff --git a/ui-wheatherapi/pom.xml b/ui-wheatherapi/pom.xml new file mode 100644 index 0000000..e65b0c5 --- /dev/null +++ b/ui-wheatherapi/pom.xml @@ -0,0 +1,49 @@ + + + 4.0.0 + + org.example + WheatherapiProject + 1.0-SNAPSHOT + + + ui-wheatherapi + + + 17 + 17 + UTF-8 + + + + + com.codeborne + selenide + 7.6.1 + + + + org.testng + testng + 7.10.2 + test + + + + net.datafaker + datafaker + 2.4.2 + + + + org.projectlombok + lombok + 1.18.36 + provided + + + + + \ No newline at end of file diff --git a/ui-wheatherapi/src/main/java/com/wheatherapi/ui/pages/MainPage.java b/ui-wheatherapi/src/main/java/com/wheatherapi/ui/pages/MainPage.java new file mode 100644 index 0000000..2bb6ac5 --- /dev/null +++ b/ui-wheatherapi/src/main/java/com/wheatherapi/ui/pages/MainPage.java @@ -0,0 +1,12 @@ +package com.wheatherapi.ui.pages; + +import static com.codeborne.selenide.Selenide.open; + +public class MainPage { + public MainPage(String mainPage){ + open(mainPage); + + } + + +} diff --git a/ui-wheatherapi/src/main/java/utils/ConfigurateBrowserSettings.java b/ui-wheatherapi/src/main/java/utils/ConfigurateBrowserSettings.java new file mode 100644 index 0000000..9132645 --- /dev/null +++ b/ui-wheatherapi/src/main/java/utils/ConfigurateBrowserSettings.java @@ -0,0 +1,12 @@ +package utils; + +import com.codeborne.selenide.Configuration; + +public class ConfigurateBrowserSettings { + public void setUp(){ + Configuration.browserSize = "1980x1080"; + Configuration.browser = "chrome"; + Configuration.timeout = 5; + //Configuration.headless = true; + } +} diff --git a/ui-wheatherapi/src/test/java/com/wheatherapi/ui/tests/TodaysWeatherForecasTest.java b/ui-wheatherapi/src/test/java/com/wheatherapi/ui/tests/TodaysWeatherForecasTest.java new file mode 100644 index 0000000..98b0751 --- /dev/null +++ b/ui-wheatherapi/src/test/java/com/wheatherapi/ui/tests/TodaysWeatherForecasTest.java @@ -0,0 +1,25 @@ +package com.wheatherapi.ui.tests; + +import com.wheatherapi.ui.pages.MainPage; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import utils.ConfigurateBrowserSettings; + +public class TodaysWeatherForecasTest { + private final String MAIN_PAGE = "https://www.weatherapi.com/weather/"; + + @BeforeClass + void preConditions() { + new ConfigurateBrowserSettings().setUp(); + } + + @Test + void userBookShopLogin() { + new MainPage(MAIN_PAGE); + + } + + + + +} From a85884ee49ec24e84f23c67ccbd668100d9dd53f Mon Sep 17 00:00:00 2001 From: Kofanskih Date: Wed, 19 Feb 2025 23:08:55 +0200 Subject: [PATCH 02/12] Add Main page, utils, first test, poms files --- ui-wheatherapi/pom.xml | 6 +++ .../ui/pages/MainPage.java | 4 +- .../com/weatherapi/ui/pages/TodayPage.java | 31 ++++++++++++++ .../ui/tests/TodaysWeatherForecasTest.java | 41 +++++++++++++++++++ 4 files changed, 79 insertions(+), 3 deletions(-) rename ui-wheatherapi/src/main/java/com/{wheatherapi => weatherapi}/ui/pages/MainPage.java (78%) create mode 100644 ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TodayPage.java create mode 100644 ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TodaysWeatherForecasTest.java diff --git a/ui-wheatherapi/pom.xml b/ui-wheatherapi/pom.xml index e65b0c5..3dbcb6f 100644 --- a/ui-wheatherapi/pom.xml +++ b/ui-wheatherapi/pom.xml @@ -43,6 +43,12 @@ 1.18.36 provided + + org.testng + testng + 7.10.2 + compile + diff --git a/ui-wheatherapi/src/main/java/com/wheatherapi/ui/pages/MainPage.java b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/MainPage.java similarity index 78% rename from ui-wheatherapi/src/main/java/com/wheatherapi/ui/pages/MainPage.java rename to ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/MainPage.java index 2bb6ac5..45d4062 100644 --- a/ui-wheatherapi/src/main/java/com/wheatherapi/ui/pages/MainPage.java +++ b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/MainPage.java @@ -1,4 +1,4 @@ -package com.wheatherapi.ui.pages; +package com.weatherapi.ui.pages; import static com.codeborne.selenide.Selenide.open; @@ -7,6 +7,4 @@ public MainPage(String mainPage){ open(mainPage); } - - } diff --git a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TodayPage.java b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TodayPage.java new file mode 100644 index 0000000..85a7526 --- /dev/null +++ b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TodayPage.java @@ -0,0 +1,31 @@ +package com.weatherapi.ui.pages; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.SelenideElement; +import com.codeborne.selenide.WebDriverRunner; +import org.testng.Assert; + +import static com.codeborne.selenide.Selenide.$; + +public class TodayPage { + private final SelenideElement todayButton = $("[class=\"p-2 h4\"][title=\"Today weather\"]"); + private final String todayURL = "https://www.weatherapi.com/weather/q/benidorm-699566"; + private final SelenideElement todayElement = $("[href=\"/weather/q/benidorm-699566\"][title=\"Today weather\"]"); + public final String textElementToday = "Today"; + + public TodayPage goToTodayPage(){ + todayButton.click(); + return new TodayPage(); + } + + public TodayPage checkTodayPageURL(){ + Assert.assertEquals(WebDriverRunner.getWebDriver().getCurrentUrl(), todayURL); + return this; + } + + public TodayPage checkTodayPageElements(){ + todayElement.shouldHave(Condition.exactText(textElementToday)); + return this; + } + +} diff --git a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TodaysWeatherForecasTest.java b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TodaysWeatherForecasTest.java new file mode 100644 index 0000000..bc2fef8 --- /dev/null +++ b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TodaysWeatherForecasTest.java @@ -0,0 +1,41 @@ +package com.weatherapi.ui.tests; + +import com.weatherapi.ui.pages.MainPage; +import com.weatherapi.ui.pages.TodayPage; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import utils.ConfigurateBrowserSettings; + +public class TodaysWeatherForecasTest { + private final String MAIN_PAGE = "https://www.weatherapi.com/weather/"; + + @BeforeClass + void preConditionsClass() { + new ConfigurateBrowserSettings().setUp(); + } + @BeforeMethod + void preConditionsMethod(){ + new MainPage(MAIN_PAGE); + } + + @Test + void userGoToTodayPageV1() { + new TodayPage() + .goToTodayPage() + .checkTodayPageURL(); + + } + + @Test + void userGoToTodayPageV2() { + new TodayPage() + .goToTodayPage() + .checkTodayPageElements(); + + } + + + + +} From ee48dd5c8d041fed615f7b7eaed398ea759d24b6 Mon Sep 17 00:00:00 2001 From: Kofanskih Date: Wed, 19 Feb 2025 23:11:21 +0200 Subject: [PATCH 03/12] Add Today page --- .../src/main/java/com/weatherapi/ui/pages/TodayPage.java | 1 - 1 file changed, 1 deletion(-) diff --git a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TodayPage.java b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TodayPage.java index 85a7526..41e7508 100644 --- a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TodayPage.java +++ b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TodayPage.java @@ -4,7 +4,6 @@ import com.codeborne.selenide.SelenideElement; import com.codeborne.selenide.WebDriverRunner; import org.testng.Assert; - import static com.codeborne.selenide.Selenide.$; public class TodayPage { From 7bd85a1cabf7cf07a502db228d31fe4216942266 Mon Sep 17 00:00:00 2001 From: Kofanskih Date: Wed, 19 Feb 2025 23:27:24 +0200 Subject: [PATCH 04/12] Add Tomorrow and History pages, update gitignore --- .gitignore | 4 ++- .../com/weatherapi/ui/pages/HistoryPage.java | 30 +++++++++++++++++++ .../com/weatherapi/ui/pages/TomorrowPage.java | 30 +++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/HistoryPage.java create mode 100644 ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TomorrowPage.java diff --git a/.gitignore b/.gitignore index 62c8935..6e966e2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -.idea/ \ No newline at end of file +.idea/ +ui-wheatherapi/build/ +ui-wheatherapi/target/ \ No newline at end of file diff --git a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/HistoryPage.java b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/HistoryPage.java new file mode 100644 index 0000000..8f83650 --- /dev/null +++ b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/HistoryPage.java @@ -0,0 +1,30 @@ +package com.weatherapi.ui.pages; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.SelenideElement; +import com.codeborne.selenide.WebDriverRunner; +import org.testng.Assert; + +import static com.codeborne.selenide.Selenide.$; + +public class HistoryPage { + private final SelenideElement historyButton = $("[class=\"p-2\"][title=\"Benidorm weather history\"]"); + private final String historyURL = "https://www.weatherapi.com/history/q/benidorm-699566"; + private final SelenideElement historyElement = $("[class=\"p-2 h4\"][title=\"Benidorm weather history\"]"); + public final String textElementHistory = "History"; + + public HistoryPage goToTomorrowPage(){ + historyButton.click(); + return new HistoryPage(); + } + + public HistoryPage checkTomorrowPageURL(){ + Assert.assertEquals(WebDriverRunner.getWebDriver().getCurrentUrl(), historyURL); + return this; + } + + public HistoryPage checkTomorrowPageElements(){ + historyElement.shouldHave(Condition.exactText(textElementHistory)); + return this; + } +} diff --git a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TomorrowPage.java b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TomorrowPage.java new file mode 100644 index 0000000..053e655 --- /dev/null +++ b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TomorrowPage.java @@ -0,0 +1,30 @@ +package com.weatherapi.ui.pages; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.SelenideElement; +import com.codeborne.selenide.WebDriverRunner; +import org.testng.Assert; + +import static com.codeborne.selenide.Selenide.$; + +public class TomorrowPage { + private final SelenideElement tomorrowButton = $("[class=\"p-2\"][title=\"Tomorrow weather\"]"); + private final String tomorrowURL = "https://www.weatherapi.com/weather/q/benidorm-699566?day=1"; + private final SelenideElement tomorrowElement = $("[href=\"/weather/q/benidorm-699566\"][title=\"Tomorrow weather\"]"); + public final String textElementTomorrow = "Tomorrow"; + + public TomorrowPage goToTomorrowPage(){ + tomorrowButton.click(); + return new TomorrowPage(); + } + + public TomorrowPage checkTomorrowPageURL(){ + Assert.assertEquals(WebDriverRunner.getWebDriver().getCurrentUrl(), tomorrowURL); + return this; + } + + public TomorrowPage checkTomorrowPageElements(){ + tomorrowElement.shouldHave(Condition.exactText(textElementTomorrow)); + return this; + } +} From 9fc39e197821a605cab6b952c25c7d63fbdbc760 Mon Sep 17 00:00:00 2001 From: Kofanskih Date: Thu, 20 Feb 2025 16:32:20 +0200 Subject: [PATCH 05/12] Add Today page --- .../com/weatherapi/ui/pages/TomorrowPage.java | 2 +- .../ui/tests/TodaysWeatherForecasTest.java | 4 +- .../weatherapi/ui/tests/TomorrowWeather.java | 38 +++++++++++++++++++ 3 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TomorrowWeather.java diff --git a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TomorrowPage.java b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TomorrowPage.java index 053e655..6af5fa1 100644 --- a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TomorrowPage.java +++ b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TomorrowPage.java @@ -10,7 +10,7 @@ public class TomorrowPage { private final SelenideElement tomorrowButton = $("[class=\"p-2\"][title=\"Tomorrow weather\"]"); private final String tomorrowURL = "https://www.weatherapi.com/weather/q/benidorm-699566?day=1"; - private final SelenideElement tomorrowElement = $("[href=\"/weather/q/benidorm-699566\"][title=\"Tomorrow weather\"]"); + private final SelenideElement tomorrowElement = $("[href=\"/weather/q/benidorm-699566?day=1\"][title=\"Tomorrow weather\"]"); public final String textElementTomorrow = "Tomorrow"; public TomorrowPage goToTomorrowPage(){ diff --git a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TodaysWeatherForecasTest.java b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TodaysWeatherForecasTest.java index bc2fef8..66a1e8d 100644 --- a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TodaysWeatherForecasTest.java +++ b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TodaysWeatherForecasTest.java @@ -14,6 +14,7 @@ public class TodaysWeatherForecasTest { void preConditionsClass() { new ConfigurateBrowserSettings().setUp(); } + @BeforeMethod void preConditionsMethod(){ new MainPage(MAIN_PAGE); @@ -35,7 +36,4 @@ void userGoToTodayPageV2() { } - - - } diff --git a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TomorrowWeather.java b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TomorrowWeather.java new file mode 100644 index 0000000..8216d31 --- /dev/null +++ b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TomorrowWeather.java @@ -0,0 +1,38 @@ +package com.weatherapi.ui.tests; + +import com.weatherapi.ui.pages.MainPage; +import com.weatherapi.ui.pages.TomorrowPage; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import utils.ConfigurateBrowserSettings; + +public class TomorrowWeather { + private final String MAIN_PAGE = "https://www.weatherapi.com/weather/"; + + @BeforeClass + void preConditionsClass() { + new ConfigurateBrowserSettings().setUp(); + } + + @BeforeMethod + void preConditionsMethod(){ + new MainPage(MAIN_PAGE); + } + + @Test + void userGoToTomorrowPageV1() { + new TomorrowPage() + .goToTomorrowPage() + .checkTomorrowPageURL(); + + } + + @Test + void userGoToTomorrowPageV2() { + new TomorrowPage() + .goToTomorrowPage() + .checkTomorrowPageElements(); + + } +} From d932da6cc6fe60b8d697b041ded0409a891e2bcf Mon Sep 17 00:00:00 2001 From: Kofanskih Date: Fri, 21 Feb 2025 16:58:42 +0200 Subject: [PATCH 06/12] Resolve comments from PR --- .../main/java/com/weatherapi/ui/pages/HistoryPage.java | 6 +++--- .../src/main/java/com/weatherapi/ui/pages/MainPage.java | 8 ++++++-- .../src/main/java/com/weatherapi/ui/pages/TodayPage.java | 2 +- .../main/java/com/weatherapi/ui/pages/TomorrowPage.java | 2 +- .../weatherapi/ui/tests/TodaysWeatherForecasTest.java | 8 +++++--- .../java/com/weatherapi/ui/tests/TomorrowWeather.java | 9 ++++++--- 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/HistoryPage.java b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/HistoryPage.java index 8f83650..805c4a0 100644 --- a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/HistoryPage.java +++ b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/HistoryPage.java @@ -13,17 +13,17 @@ public class HistoryPage { private final SelenideElement historyElement = $("[class=\"p-2 h4\"][title=\"Benidorm weather history\"]"); public final String textElementHistory = "History"; - public HistoryPage goToTomorrowPage(){ + public HistoryPage clickHistoryButton(){ historyButton.click(); return new HistoryPage(); } - public HistoryPage checkTomorrowPageURL(){ + public HistoryPage checkHistoryPageURL(){ Assert.assertEquals(WebDriverRunner.getWebDriver().getCurrentUrl(), historyURL); return this; } - public HistoryPage checkTomorrowPageElements(){ + public HistoryPage checkHistoryPageElements(){ historyElement.shouldHave(Condition.exactText(textElementHistory)); return this; } diff --git a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/MainPage.java b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/MainPage.java index 45d4062..698dc5e 100644 --- a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/MainPage.java +++ b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/MainPage.java @@ -1,10 +1,14 @@ package com.weatherapi.ui.pages; +import com.codeborne.selenide.Selenide; + import static com.codeborne.selenide.Selenide.open; public class MainPage { - public MainPage(String mainPage){ - open(mainPage); + private final String MAIN_PAGE = "https://www.weatherapi.com/weather/"; + public MainPage open() { + Selenide.open(MAIN_PAGE); + return new MainPage(); } } diff --git a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TodayPage.java b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TodayPage.java index 41e7508..07ebc88 100644 --- a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TodayPage.java +++ b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TodayPage.java @@ -12,7 +12,7 @@ public class TodayPage { private final SelenideElement todayElement = $("[href=\"/weather/q/benidorm-699566\"][title=\"Today weather\"]"); public final String textElementToday = "Today"; - public TodayPage goToTodayPage(){ + public TodayPage clickTodayButton(){ todayButton.click(); return new TodayPage(); } diff --git a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TomorrowPage.java b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TomorrowPage.java index 6af5fa1..5687f3c 100644 --- a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TomorrowPage.java +++ b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/TomorrowPage.java @@ -13,7 +13,7 @@ public class TomorrowPage { private final SelenideElement tomorrowElement = $("[href=\"/weather/q/benidorm-699566?day=1\"][title=\"Tomorrow weather\"]"); public final String textElementTomorrow = "Tomorrow"; - public TomorrowPage goToTomorrowPage(){ + public TomorrowPage clickTommorrowButton(){ tomorrowButton.click(); return new TomorrowPage(); } diff --git a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TodaysWeatherForecasTest.java b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TodaysWeatherForecasTest.java index 66a1e8d..945385a 100644 --- a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TodaysWeatherForecasTest.java +++ b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TodaysWeatherForecasTest.java @@ -6,6 +6,7 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import utils.ConfigurateBrowserSettings; +import static com.codeborne.selenide.Selenide.open; public class TodaysWeatherForecasTest { private final String MAIN_PAGE = "https://www.weatherapi.com/weather/"; @@ -17,13 +18,14 @@ void preConditionsClass() { @BeforeMethod void preConditionsMethod(){ - new MainPage(MAIN_PAGE); + open(MAIN_PAGE); + } @Test void userGoToTodayPageV1() { new TodayPage() - .goToTodayPage() + .clickTodayButton() .checkTodayPageURL(); } @@ -31,7 +33,7 @@ void userGoToTodayPageV1() { @Test void userGoToTodayPageV2() { new TodayPage() - .goToTodayPage() + .clickTodayButton() .checkTodayPageElements(); } diff --git a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TomorrowWeather.java b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TomorrowWeather.java index 8216d31..05169ea 100644 --- a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TomorrowWeather.java +++ b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TomorrowWeather.java @@ -7,6 +7,8 @@ import org.testng.annotations.Test; import utils.ConfigurateBrowserSettings; +import static com.codeborne.selenide.Selenide.open; + public class TomorrowWeather { private final String MAIN_PAGE = "https://www.weatherapi.com/weather/"; @@ -17,13 +19,14 @@ void preConditionsClass() { @BeforeMethod void preConditionsMethod(){ - new MainPage(MAIN_PAGE); + open(MAIN_PAGE); + } @Test void userGoToTomorrowPageV1() { new TomorrowPage() - .goToTomorrowPage() + .clickTommorrowButton() .checkTomorrowPageURL(); } @@ -31,7 +34,7 @@ void userGoToTomorrowPageV1() { @Test void userGoToTomorrowPageV2() { new TomorrowPage() - .goToTomorrowPage() + .clickTommorrowButton() .checkTomorrowPageElements(); } From bc62e29a0c704ee233a17a230c3864d0623e4b30 Mon Sep 17 00:00:00 2001 From: Kofanskih Date: Fri, 21 Feb 2025 23:47:11 +0200 Subject: [PATCH 07/12] Add History test --- .../com/weatherapi/ui/pages/HistoryPage.java | 12 ++++- .../utils/ConfigurateBrowserSettings.java | 2 +- .../weatherapi/ui/tests/HistoryWeather.java | 49 +++++++++++++++++++ 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/HistoryWeather.java diff --git a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/HistoryPage.java b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/HistoryPage.java index 805c4a0..a84752e 100644 --- a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/HistoryPage.java +++ b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/HistoryPage.java @@ -6,12 +6,15 @@ import org.testng.Assert; import static com.codeborne.selenide.Selenide.$; +import static com.codeborne.selenide.Selenide.$x; public class HistoryPage { private final SelenideElement historyButton = $("[class=\"p-2\"][title=\"Benidorm weather history\"]"); private final String historyURL = "https://www.weatherapi.com/history/q/benidorm-699566"; private final SelenideElement historyElement = $("[class=\"p-2 h4\"][title=\"Benidorm weather history\"]"); - public final String textElementHistory = "History"; + private final String textElementHistory = "History"; + private final SelenideElement pressureThirdElementInTable = $x("//main//tbody/tr[7]/td[5][@style=\"background-color:#C6F56F;\"]"); + private final String pressureElement = "mb"; public HistoryPage clickHistoryButton(){ historyButton.click(); @@ -27,4 +30,11 @@ public HistoryPage checkHistoryPageElements(){ historyElement.shouldHave(Condition.exactText(textElementHistory)); return this; } + + public HistoryPage checkPressureData(){ + pressureThirdElementInTable.shouldHave(Condition.partialText(pressureElement)); + return this; + } + + } diff --git a/ui-wheatherapi/src/main/java/utils/ConfigurateBrowserSettings.java b/ui-wheatherapi/src/main/java/utils/ConfigurateBrowserSettings.java index 9132645..7430d7f 100644 --- a/ui-wheatherapi/src/main/java/utils/ConfigurateBrowserSettings.java +++ b/ui-wheatherapi/src/main/java/utils/ConfigurateBrowserSettings.java @@ -7,6 +7,6 @@ public void setUp(){ Configuration.browserSize = "1980x1080"; Configuration.browser = "chrome"; Configuration.timeout = 5; - //Configuration.headless = true; + Configuration.headless = true; } } diff --git a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/HistoryWeather.java b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/HistoryWeather.java new file mode 100644 index 0000000..4a32f4a --- /dev/null +++ b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/HistoryWeather.java @@ -0,0 +1,49 @@ +package com.weatherapi.ui.tests; + +import com.weatherapi.ui.pages.HistoryPage; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import utils.ConfigurateBrowserSettings; + +import static com.codeborne.selenide.Selenide.open; + +public class HistoryWeather { + private final String MAIN_PAGE = "https://www.weatherapi.com/weather/"; + + @BeforeClass + void preConditionsClass() { + new ConfigurateBrowserSettings().setUp(); + } + + @BeforeMethod + void preConditionsMethod(){ + open(MAIN_PAGE); + + } + + @Test + void userGoToHistoryPageV1() { + new HistoryPage() + .clickHistoryButton() + .checkHistoryPageURL(); + + } + + @Test + void userGoToHistoryPageV2() { + new HistoryPage() + .clickHistoryButton() + .checkHistoryPageElements(); + + } + + @Test + void verifyPressureElementInTheHistoryTable(){ + new HistoryPage() + .clickHistoryButton() + .checkPressureData(); + } + + +} From 44b077fcc5b08812976705da648b23ccd6656ddd Mon Sep 17 00:00:00 2001 From: Kofanskih Date: Sat, 22 Feb 2025 16:38:25 +0200 Subject: [PATCH 08/12] Add Login, Personal pages, Login Test, update Main Page --- .../com/weatherapi/ui/pages/LoginPage.java | 56 ++++++++++++++ .../com/weatherapi/ui/pages/MainPage.java | 10 ++- .../com/weatherapi/ui/pages/PersonalPage.java | 15 ++++ .../ui/tests/LoginWeatherapiTest.java | 74 +++++++++++++++++++ 4 files changed, 153 insertions(+), 2 deletions(-) create mode 100644 ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/LoginPage.java create mode 100644 ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/PersonalPage.java create mode 100644 ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/LoginWeatherapiTest.java diff --git a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/LoginPage.java b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/LoginPage.java new file mode 100644 index 0000000..d65d3fa --- /dev/null +++ b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/LoginPage.java @@ -0,0 +1,56 @@ +package com.weatherapi.ui.pages; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.SelenideElement; +import static com.codeborne.selenide.Selenide.$; +import static com.codeborne.selenide.Selenide.$x; + +public class LoginPage { + private final SelenideElement emailField = $("[id=\"ctl00_MainContentHolder_Login1_UserName\"]"); + private final SelenideElement passwordField = $("[id=\"ctl00_MainContentHolder_Login1_Password\"]"); + private final SelenideElement loginButton = $("[id=\"ctl00_MainContentHolder_Login1_LoginButton\"]"); + private final SelenideElement warningMessageElement = $x("//span[@id=\"ctl00_MainContentHolder_Login1_FailureText\"]"); + + public LoginPage fillEmailField(String email) { + emailField.setValue(email); + return new LoginPage(); + } + + public LoginPage fillPasswordField(String password) { + passwordField.setValue(password); + return new LoginPage(); + } + + public PersonalPage clickLoginButton() { + loginButton.click(); + return new PersonalPage(); + } + public PersonalPage fillLoginData(String email, String password) { + emailField.setValue(email); + passwordField.setValue(password); + loginButton.click(); + return new PersonalPage(); + } + + public LoginPage fillLoginFormWithWrongPassword(String email, String wrongPassword){ + emailField.setValue(email); + passwordField.setValue(wrongPassword); + loginButton.click(); + return new LoginPage(); + } + + public LoginPage fillLoginFormWithWrongEmail(String wrongEmail, String password){ + emailField.setValue(wrongEmail); + passwordField.setValue(password); + loginButton.click(); + return new LoginPage(); + } + + public LoginPage checkWarningLoginMessage(String warningMessage){ + warningMessageElement.shouldHave(Condition.exactText(warningMessage)); + return this; + } + + + +} diff --git a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/MainPage.java b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/MainPage.java index 698dc5e..d4e6bda 100644 --- a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/MainPage.java +++ b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/MainPage.java @@ -1,14 +1,20 @@ package com.weatherapi.ui.pages; import com.codeborne.selenide.Selenide; - -import static com.codeborne.selenide.Selenide.open; +import com.codeborne.selenide.SelenideElement; +import static com.codeborne.selenide.Selenide.$; public class MainPage { private final String MAIN_PAGE = "https://www.weatherapi.com/weather/"; + private final SelenideElement loginPage = $("[href=\"/login.aspx\"]"); public MainPage open() { Selenide.open(MAIN_PAGE); return new MainPage(); } + + public LoginPage goToLoginPage(){ + loginPage.click(); + return new LoginPage(); + } } diff --git a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/PersonalPage.java b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/PersonalPage.java new file mode 100644 index 0000000..6a9ef9e --- /dev/null +++ b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/PersonalPage.java @@ -0,0 +1,15 @@ +package com.weatherapi.ui.pages; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.SelenideElement; +import static com.codeborne.selenide.Selenide.$x; + +public class PersonalPage { + private final SelenideElement personalAccount = $x("//h2[@class=\"view-title\"]"); + + public PersonalPage userShouldHaveExactTextOnTheAccountPage(String personalAccountText){ + personalAccount.shouldHave(Condition.exactTextCaseSensitive(personalAccountText)); + return new PersonalPage(); + } + +} diff --git a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/LoginWeatherapiTest.java b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/LoginWeatherapiTest.java new file mode 100644 index 0000000..40085f3 --- /dev/null +++ b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/LoginWeatherapiTest.java @@ -0,0 +1,74 @@ +package com.weatherapi.ui.tests; + +import com.weatherapi.ui.pages.LoginPage; +import com.weatherapi.ui.pages.MainPage; +import com.weatherapi.ui.pages.PersonalPage; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import utils.ConfigurateBrowserSettings; + +import static com.codeborne.selenide.Selenide.open; + +public class LoginWeatherapiTest { + private final String MAIN_PAGE = "https://www.weatherapi.com/weather/"; + private final String USER_EMAIL = "kofanskih08@gmail.com"; + private final String USER_PASSWORD = "f2H*Jap*M6@7/d_"; + private final String personalAccountText = "Welcome Back\n"; + private final String WRONG_USER_EMAIL = "kofanski08@gmail.com"; + private final String WRONG_USER_PASSWORD = "09876TYUI54321i"; + private final String WARNING_MESSAGE= "Your login attempt was not successful. Please try again."; + + + + @BeforeClass + void preConditionsClass() { + new ConfigurateBrowserSettings().setUp(); + } + + @BeforeMethod + void preConditionsMethod(){ + open(MAIN_PAGE); + + } + + @Test + void userLoginV1() { + new MainPage() + .goToLoginPage() + .fillEmailField(USER_EMAIL) + .fillPasswordField(USER_PASSWORD) + .clickLoginButton(); + new PersonalPage().userShouldHaveExactTextOnTheAccountPage(personalAccountText); + + } + + @Test + void userLoginV2() { + new MainPage() + .goToLoginPage() + .fillLoginData(USER_EMAIL, USER_PASSWORD); + new PersonalPage().userShouldHaveExactTextOnTheAccountPage(personalAccountText); + + } + + @Test + void userLoginWithWrongEmail(){ + new MainPage() + .goToLoginPage() + .fillLoginFormWithWrongEmail(WRONG_USER_EMAIL, USER_PASSWORD); + + new LoginPage().checkWarningLoginMessage(WARNING_MESSAGE); + + } + + @Test + void userLoginWithWrongPassword(){ + new MainPage() + .goToLoginPage() + .fillLoginFormWithWrongPassword(USER_EMAIL, WRONG_USER_PASSWORD); + + new LoginPage().checkWarningLoginMessage(WARNING_MESSAGE); + + } +} From 2454d9cced0753e872ea1dd9ada20f5330fbcc99 Mon Sep 17 00:00:00 2001 From: Kofanskih Date: Sat, 22 Feb 2025 21:42:27 +0200 Subject: [PATCH 09/12] Add Logout Test, update Main, Personal Pages, Login, Tommorow, Today tests --- .../com/weatherapi/ui/pages/MainPage.java | 7 ++++ .../com/weatherapi/ui/pages/PersonalPage.java | 9 ++++ .../ui/tests/LoginWeatherapiTest.java | 1 - .../com/weatherapi/ui/tests/LogoutTest.java | 41 +++++++++++++++++++ .../ui/tests/TodaysWeatherForecasTest.java | 1 - .../weatherapi/ui/tests/TomorrowWeather.java | 1 - .../ui/tests/TodaysWeatherForecasTest.java | 25 ----------- 7 files changed, 57 insertions(+), 28 deletions(-) create mode 100644 ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/LogoutTest.java delete mode 100644 ui-wheatherapi/src/test/java/com/wheatherapi/ui/tests/TodaysWeatherForecasTest.java diff --git a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/MainPage.java b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/MainPage.java index d4e6bda..7934342 100644 --- a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/MainPage.java +++ b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/MainPage.java @@ -1,5 +1,6 @@ package com.weatherapi.ui.pages; +import com.codeborne.selenide.Condition; import com.codeborne.selenide.Selenide; import com.codeborne.selenide.SelenideElement; import static com.codeborne.selenide.Selenide.$; @@ -7,6 +8,7 @@ public class MainPage { private final String MAIN_PAGE = "https://www.weatherapi.com/weather/"; private final SelenideElement loginPage = $("[href=\"/login.aspx\"]"); + public final String loginButton = "Login"; public MainPage open() { Selenide.open(MAIN_PAGE); @@ -17,4 +19,9 @@ public LoginPage goToLoginPage(){ loginPage.click(); return new LoginPage(); } + + public MainPage checkUserLogout(){ + loginPage.shouldHave(Condition.exactText(loginButton)); + return new MainPage(); + } } diff --git a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/PersonalPage.java b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/PersonalPage.java index 6a9ef9e..7f368b2 100644 --- a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/PersonalPage.java +++ b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/PersonalPage.java @@ -2,14 +2,23 @@ import com.codeborne.selenide.Condition; import com.codeborne.selenide.SelenideElement; +import static com.codeborne.selenide.Selenide.$; import static com.codeborne.selenide.Selenide.$x; public class PersonalPage { private final SelenideElement personalAccount = $x("//h2[@class=\"view-title\"]"); + private final SelenideElement logoutButton = $("[href=\"/logout.aspx\"]"); + public PersonalPage userShouldHaveExactTextOnTheAccountPage(String personalAccountText){ personalAccount.shouldHave(Condition.exactTextCaseSensitive(personalAccountText)); return new PersonalPage(); } + public MainPage logout(){ + logoutButton.click(); + return new MainPage(); + } + + } diff --git a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/LoginWeatherapiTest.java b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/LoginWeatherapiTest.java index 40085f3..d238159 100644 --- a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/LoginWeatherapiTest.java +++ b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/LoginWeatherapiTest.java @@ -7,7 +7,6 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import utils.ConfigurateBrowserSettings; - import static com.codeborne.selenide.Selenide.open; public class LoginWeatherapiTest { diff --git a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/LogoutTest.java b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/LogoutTest.java new file mode 100644 index 0000000..6f56e87 --- /dev/null +++ b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/LogoutTest.java @@ -0,0 +1,41 @@ +package com.weatherapi.ui.tests; + +import com.weatherapi.ui.pages.MainPage; +import com.weatherapi.ui.pages.PersonalPage; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import utils.ConfigurateBrowserSettings; +import static com.codeborne.selenide.Selenide.open; + + +public class LogoutTest { + private final String USER_EMAIL = "kofanskih08@gmail.com"; + private final String USER_PASSWORD = "f2H*Jap*M6@7/d_"; + private final String MAIN_PAGE = "https://www.weatherapi.com/"; + + + + + @BeforeClass + void preConditions() { + new ConfigurateBrowserSettings().setUp(); + } + + @BeforeMethod + void userLogin() { + open(MAIN_PAGE); + new MainPage() + .goToLoginPage() + .fillLoginData(USER_EMAIL, USER_PASSWORD); + + } + + @Test + void userBookShopLogout() { + new PersonalPage() + .logout() + .checkUserLogout(); + + } +} diff --git a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TodaysWeatherForecasTest.java b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TodaysWeatherForecasTest.java index 945385a..55a3242 100644 --- a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TodaysWeatherForecasTest.java +++ b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TodaysWeatherForecasTest.java @@ -1,6 +1,5 @@ package com.weatherapi.ui.tests; -import com.weatherapi.ui.pages.MainPage; import com.weatherapi.ui.pages.TodayPage; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; diff --git a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TomorrowWeather.java b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TomorrowWeather.java index 05169ea..9f21b33 100644 --- a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TomorrowWeather.java +++ b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/TomorrowWeather.java @@ -1,6 +1,5 @@ package com.weatherapi.ui.tests; -import com.weatherapi.ui.pages.MainPage; import com.weatherapi.ui.pages.TomorrowPage; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; diff --git a/ui-wheatherapi/src/test/java/com/wheatherapi/ui/tests/TodaysWeatherForecasTest.java b/ui-wheatherapi/src/test/java/com/wheatherapi/ui/tests/TodaysWeatherForecasTest.java deleted file mode 100644 index 98b0751..0000000 --- a/ui-wheatherapi/src/test/java/com/wheatherapi/ui/tests/TodaysWeatherForecasTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.wheatherapi.ui.tests; - -import com.wheatherapi.ui.pages.MainPage; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import utils.ConfigurateBrowserSettings; - -public class TodaysWeatherForecasTest { - private final String MAIN_PAGE = "https://www.weatherapi.com/weather/"; - - @BeforeClass - void preConditions() { - new ConfigurateBrowserSettings().setUp(); - } - - @Test - void userBookShopLogin() { - new MainPage(MAIN_PAGE); - - } - - - - -} From 69bafcf514864b32ca34659ab3ad9142f0afd831 Mon Sep 17 00:00:00 2001 From: Kofanskih Date: Tue, 25 Feb 2025 20:21:25 +0200 Subject: [PATCH 10/12] Update History page, History tests --- .../com/weatherapi/ui/pages/HistoryPage.java | 22 +++++++++++++++++-- .../com/weatherapi/ui/pages/MainPage.java | 2 +- .../weatherapi/ui/tests/HistoryWeather.java | 17 ++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/HistoryPage.java b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/HistoryPage.java index a84752e..8c33151 100644 --- a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/HistoryPage.java +++ b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/HistoryPage.java @@ -1,12 +1,13 @@ package com.weatherapi.ui.pages; import com.codeborne.selenide.Condition; +import com.codeborne.selenide.ElementsCollection; import com.codeborne.selenide.SelenideElement; import com.codeborne.selenide.WebDriverRunner; +import org.openqa.selenium.By; import org.testng.Assert; -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$x; +import static com.codeborne.selenide.Selenide.*; public class HistoryPage { private final SelenideElement historyButton = $("[class=\"p-2\"][title=\"Benidorm weather history\"]"); @@ -15,6 +16,13 @@ public class HistoryPage { private final String textElementHistory = "History"; private final SelenideElement pressureThirdElementInTable = $x("//main//tbody/tr[7]/td[5][@style=\"background-color:#C6F56F;\"]"); private final String pressureElement = "mb"; + private final ElementsCollection tableWeatherIn = $$(By.tagName("td")); + private final String windElementInTheTableWeatherIn = tableWeatherIn.get(22).getText(); + private final String windElement = "kmph"; + private final String hourElementInTheTableAnnualWeatherAverages = tableWeatherIn.get(115).getText(); + private final String hourElement = "hours"; + + public HistoryPage clickHistoryButton(){ historyButton.click(); @@ -36,5 +44,15 @@ public HistoryPage checkPressureData(){ return this; } + public HistoryPage checkWindElementInHistoryTable(){ + Assert.assertTrue(windElementInTheTableWeatherIn.endsWith(windElement)); + return this; + } + + public HistoryPage checkHoursElementInHistoryTable(){ + Assert.assertTrue(hourElementInTheTableAnnualWeatherAverages.endsWith(hourElement)); + return this; + } + } diff --git a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/MainPage.java b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/MainPage.java index 7934342..2846825 100644 --- a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/MainPage.java +++ b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/MainPage.java @@ -10,7 +10,7 @@ public class MainPage { private final SelenideElement loginPage = $("[href=\"/login.aspx\"]"); public final String loginButton = "Login"; - public MainPage open() { + public MainPage open() { Selenide.open(MAIN_PAGE); return new MainPage(); } diff --git a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/HistoryWeather.java b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/HistoryWeather.java index 4a32f4a..e6fee06 100644 --- a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/HistoryWeather.java +++ b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/HistoryWeather.java @@ -1,6 +1,7 @@ package com.weatherapi.ui.tests; import com.weatherapi.ui.pages.HistoryPage; + import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -11,6 +12,7 @@ public class HistoryWeather { private final String MAIN_PAGE = "https://www.weatherapi.com/weather/"; + @BeforeClass void preConditionsClass() { new ConfigurateBrowserSettings().setUp(); @@ -45,5 +47,20 @@ void verifyPressureElementInTheHistoryTable(){ .checkPressureData(); } + @Test + void checkElementInTable(){ + new HistoryPage() + .clickHistoryButton() + .checkWindElementInHistoryTable(); + + } + + @Test + void checkHoursElementInWeatherAveragesTable(){ + new HistoryPage() + .clickHistoryButton() + .checkHoursElementInHistoryTable(); + + } } From d328a397639a7eaf4beec705eff18f89f60bc3c1 Mon Sep 17 00:00:00 2001 From: Kofanskih Date: Tue, 25 Feb 2025 20:38:33 +0200 Subject: [PATCH 11/12] Update poms --- pom.xml | 18 ++++++++++++++++++ ui-wheatherapi/pom.xml | 25 ------------------------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/pom.xml b/pom.xml index 89b0ead..b9124f5 100644 --- a/pom.xml +++ b/pom.xml @@ -19,6 +19,24 @@ + + net.datafaker + datafaker + 2.4.2 + + + + org.projectlombok + lombok + 1.18.36 + provided + + + + org.testng + testng + 7.10.2 + diff --git a/ui-wheatherapi/pom.xml b/ui-wheatherapi/pom.xml index 3dbcb6f..dba2b75 100644 --- a/ui-wheatherapi/pom.xml +++ b/ui-wheatherapi/pom.xml @@ -24,31 +24,6 @@ 7.6.1 - - org.testng - testng - 7.10.2 - test - - - - net.datafaker - datafaker - 2.4.2 - - - - org.projectlombok - lombok - 1.18.36 - provided - - - org.testng - testng - 7.10.2 - compile - From e54dedaca6d1270ae9ad38e1135f2cbef11fb1df Mon Sep 17 00:00:00 2001 From: Kofanskih Date: Tue, 25 Feb 2025 21:54:06 +0200 Subject: [PATCH 12/12] Add LoginUserPageModel Update Login page, Login and Logout tests --- .../ui/pageModels/LoginUserPageModel.java | 31 +++++++++++++++++ .../com/weatherapi/ui/pages/LoginPage.java | 34 ++++++------------- .../ui/tests/LoginWeatherapiTest.java | 26 +++----------- .../com/weatherapi/ui/tests/LogoutTest.java | 8 ++--- 4 files changed, 49 insertions(+), 50 deletions(-) create mode 100644 ui-wheatherapi/src/main/java/com/weatherapi/ui/pageModels/LoginUserPageModel.java diff --git a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pageModels/LoginUserPageModel.java b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pageModels/LoginUserPageModel.java new file mode 100644 index 0000000..0befee1 --- /dev/null +++ b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pageModels/LoginUserPageModel.java @@ -0,0 +1,31 @@ +package com.weatherapi.ui.pageModels; + +import lombok.Data; + +@Data +public class LoginUserPageModel { + private String USER_EMAIL; + private String USER_PASSWORD; + private String WRONG_USER_EMAIL; + private String WRONG_USER_PASSWORD; + + public LoginUserPageModel userLogin(){ + this.USER_EMAIL = "kofanskih08@gmail.com"; + this.USER_PASSWORD = "f2H*Jap*M6@7/d_"; + return this; + } + + public LoginUserPageModel userLoginWithWrongEmail(){ + this.WRONG_USER_EMAIL = "kofanski08@gmail.com"; + this.USER_PASSWORD = "f2H*Jap*M6@7/d_"; + return this; + } + + public LoginUserPageModel userLoginWithWrongPassword(){ + this.USER_EMAIL = "kofanskih08@gmail.com"; + this.WRONG_USER_PASSWORD = "f2H*Jap*M6@7/d_1"; + return this; + } + + +} diff --git a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/LoginPage.java b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/LoginPage.java index d65d3fa..5c94a08 100644 --- a/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/LoginPage.java +++ b/ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/LoginPage.java @@ -2,6 +2,8 @@ import com.codeborne.selenide.Condition; import com.codeborne.selenide.SelenideElement; +import com.weatherapi.ui.pageModels.LoginUserPageModel; + import static com.codeborne.selenide.Selenide.$; import static com.codeborne.selenide.Selenide.$x; @@ -11,37 +13,23 @@ public class LoginPage { private final SelenideElement loginButton = $("[id=\"ctl00_MainContentHolder_Login1_LoginButton\"]"); private final SelenideElement warningMessageElement = $x("//span[@id=\"ctl00_MainContentHolder_Login1_FailureText\"]"); - public LoginPage fillEmailField(String email) { - emailField.setValue(email); - return new LoginPage(); - } - - public LoginPage fillPasswordField(String password) { - passwordField.setValue(password); - return new LoginPage(); - } - - public PersonalPage clickLoginButton() { - loginButton.click(); - return new PersonalPage(); - } - public PersonalPage fillLoginData(String email, String password) { - emailField.setValue(email); - passwordField.setValue(password); + public PersonalPage fillLoginDataWithUserModel(LoginUserPageModel loginUserPageModel) { + emailField.setValue(loginUserPageModel.getUSER_EMAIL()); + passwordField.setValue(loginUserPageModel.getUSER_PASSWORD()); loginButton.click(); return new PersonalPage(); } - public LoginPage fillLoginFormWithWrongPassword(String email, String wrongPassword){ - emailField.setValue(email); - passwordField.setValue(wrongPassword); + public LoginPage fillLoginFormWithWrongPassword(LoginUserPageModel loginUserPageModel){ + emailField.setValue(loginUserPageModel.getUSER_EMAIL()); + passwordField.setValue(loginUserPageModel.getWRONG_USER_PASSWORD()); loginButton.click(); return new LoginPage(); } - public LoginPage fillLoginFormWithWrongEmail(String wrongEmail, String password){ - emailField.setValue(wrongEmail); - passwordField.setValue(password); + public LoginPage fillLoginFormWithWrongEmail(LoginUserPageModel loginUserPageModel){ + emailField.setValue(loginUserPageModel.getWRONG_USER_EMAIL()); + passwordField.setValue(loginUserPageModel.getUSER_PASSWORD()); loginButton.click(); return new LoginPage(); } diff --git a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/LoginWeatherapiTest.java b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/LoginWeatherapiTest.java index d238159..1822ec6 100644 --- a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/LoginWeatherapiTest.java +++ b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/LoginWeatherapiTest.java @@ -1,5 +1,6 @@ package com.weatherapi.ui.tests; +import com.weatherapi.ui.pageModels.LoginUserPageModel; import com.weatherapi.ui.pages.LoginPage; import com.weatherapi.ui.pages.MainPage; import com.weatherapi.ui.pages.PersonalPage; @@ -11,11 +12,7 @@ public class LoginWeatherapiTest { private final String MAIN_PAGE = "https://www.weatherapi.com/weather/"; - private final String USER_EMAIL = "kofanskih08@gmail.com"; - private final String USER_PASSWORD = "f2H*Jap*M6@7/d_"; private final String personalAccountText = "Welcome Back\n"; - private final String WRONG_USER_EMAIL = "kofanski08@gmail.com"; - private final String WRONG_USER_PASSWORD = "09876TYUI54321i"; private final String WARNING_MESSAGE= "Your login attempt was not successful. Please try again."; @@ -32,21 +29,10 @@ void preConditionsMethod(){ } @Test - void userLoginV1() { + void userLogin() { new MainPage() .goToLoginPage() - .fillEmailField(USER_EMAIL) - .fillPasswordField(USER_PASSWORD) - .clickLoginButton(); - new PersonalPage().userShouldHaveExactTextOnTheAccountPage(personalAccountText); - - } - - @Test - void userLoginV2() { - new MainPage() - .goToLoginPage() - .fillLoginData(USER_EMAIL, USER_PASSWORD); + .fillLoginDataWithUserModel(new LoginUserPageModel().userLogin()); new PersonalPage().userShouldHaveExactTextOnTheAccountPage(personalAccountText); } @@ -55,8 +41,7 @@ void userLoginV2() { void userLoginWithWrongEmail(){ new MainPage() .goToLoginPage() - .fillLoginFormWithWrongEmail(WRONG_USER_EMAIL, USER_PASSWORD); - + .fillLoginFormWithWrongEmail(new LoginUserPageModel().userLoginWithWrongEmail()); new LoginPage().checkWarningLoginMessage(WARNING_MESSAGE); } @@ -65,8 +50,7 @@ void userLoginWithWrongEmail(){ void userLoginWithWrongPassword(){ new MainPage() .goToLoginPage() - .fillLoginFormWithWrongPassword(USER_EMAIL, WRONG_USER_PASSWORD); - + .fillLoginFormWithWrongPassword(new LoginUserPageModel().userLoginWithWrongPassword()); new LoginPage().checkWarningLoginMessage(WARNING_MESSAGE); } diff --git a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/LogoutTest.java b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/LogoutTest.java index 6f56e87..febb279 100644 --- a/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/LogoutTest.java +++ b/ui-wheatherapi/src/test/java/com/weatherapi/ui/tests/LogoutTest.java @@ -1,5 +1,6 @@ package com.weatherapi.ui.tests; +import com.weatherapi.ui.pageModels.LoginUserPageModel; import com.weatherapi.ui.pages.MainPage; import com.weatherapi.ui.pages.PersonalPage; import org.testng.annotations.BeforeClass; @@ -10,13 +11,8 @@ public class LogoutTest { - private final String USER_EMAIL = "kofanskih08@gmail.com"; - private final String USER_PASSWORD = "f2H*Jap*M6@7/d_"; private final String MAIN_PAGE = "https://www.weatherapi.com/"; - - - @BeforeClass void preConditions() { new ConfigurateBrowserSettings().setUp(); @@ -27,7 +23,7 @@ void userLogin() { open(MAIN_PAGE); new MainPage() .goToLoginPage() - .fillLoginData(USER_EMAIL, USER_PASSWORD); + .fillLoginDataWithUserModel(new LoginUserPageModel().userLogin()); }