-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ui-01] Work with Wheather ui branch #1
base: master
Are you sure you want to change the base?
Changes from all commits
0a7b0ef
a85884e
ee48dd5
7bd85a1
9fc39e1
d932da6
bc62e29
44b077f
2454d9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
.idea/ | ||
.idea/ | ||
ui-wheatherapi/build/ | ||
ui-wheatherapi/target/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.example</groupId> | ||
<artifactId>WheatherapiProject</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>ui-wheatherapi</artifactId> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.codeborne</groupId> | ||
<artifactId>selenide</artifactId> | ||
<version>7.6.1</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<version>7.10.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>net.datafaker</groupId> | ||
<artifactId>datafaker</artifactId> | ||
<version>2.4.2</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>1.18.36</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<version>7.10.2</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
Comment on lines
+34
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move in global pom |
||
|
||
</dependencies> | ||
|
||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
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.$; | ||
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\"]"); | ||
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(); | ||
return new HistoryPage(); | ||
} | ||
|
||
public HistoryPage checkHistoryPageURL(){ | ||
Assert.assertEquals(WebDriverRunner.getWebDriver().getCurrentUrl(), historyURL); | ||
return this; | ||
} | ||
|
||
public HistoryPage checkHistoryPageElements(){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should add parameter in method public HistoryPage checkHistoryPageElements(){ |
||
historyElement.shouldHave(Condition.exactText(textElementHistory)); | ||
return this; | ||
} | ||
|
||
public HistoryPage checkPressureData(){ | ||
pressureThirdElementInTable.shouldHave(Condition.partialText(pressureElement)); | ||
return this; | ||
} | ||
|
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
|
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
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.$; | ||
|
||
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() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove extra space |
||
Selenide.open(MAIN_PAGE); | ||
return new MainPage(); | ||
} | ||
|
||
public LoginPage goToLoginPage(){ | ||
loginPage.click(); | ||
return new LoginPage(); | ||
} | ||
|
||
public MainPage checkUserLogout(){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add parameter in method |
||
loginPage.shouldHave(Condition.exactText(loginButton)); | ||
return new MainPage(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
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 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(); | ||
} | ||
|
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 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 clickTodayButton(){ | ||
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; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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?day=1\"][title=\"Tomorrow weather\"]"); | ||
public final String textElementTomorrow = "Tomorrow"; | ||
|
||
public TomorrowPage clickTommorrowButton(){ | ||
tomorrowButton.click(); | ||
return new TomorrowPage(); | ||
} | ||
|
||
public TomorrowPage checkTomorrowPageURL(){ | ||
Assert.assertEquals(WebDriverRunner.getWebDriver().getCurrentUrl(), tomorrowURL); | ||
return this; | ||
} | ||
|
||
public TomorrowPage checkTomorrowPageElements(){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add parametr |
||
tomorrowElement.shouldHave(Condition.exactText(textElementTomorrow)); | ||
return this; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
|
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you have 2 testng dependencies