Skip to content
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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.idea/
.idea/
ui-wheatherapi/build/
ui-wheatherapi/target/
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<artifactId>WheatherapiProject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>ui-wheatherapi</module>
</modules>

<properties>
<maven.compiler.source>17</maven.compiler.source>
Expand Down
55 changes: 55 additions & 0 deletions ui-wheatherapi/pom.xml
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>
Comment on lines +27 to +32

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


<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

Choose a reason for hiding this comment

The 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,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;
}
}
10 changes: 10 additions & 0 deletions ui-wheatherapi/src/main/java/com/weatherapi/ui/pages/MainPage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.weatherapi.ui.pages;

import static com.codeborne.selenide.Selenide.open;

public class MainPage {
public MainPage(String mainPage){
open(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 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;
}

}
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\"][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(){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add parametr

tomorrowElement.shouldHave(Condition.exactText(textElementTomorrow));
return this;
}
}
12 changes: 12 additions & 0 deletions ui-wheatherapi/src/main/java/utils/ConfigurateBrowserSettings.java
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,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/";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move in separate class


@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();

}




}
Original file line number Diff line number Diff line change
@@ -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);

}




}