Skip to content

Commit

Permalink
еÑtest: add two tests to check the title on the reviews page (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
08AlimDuiL authored Dec 9, 2023
1 parent 57f07df commit 0b6f57f
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 7 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
# justeLeStudioTests
# !простоSтудия |Java 11 | Selenium | TestNG | Maven | POM Project

Всех приветствую))

Этот репозиторий содержит автотесты для открытого проекта **!простоSтудия**, который
разрабатывается в рамках практики от [PINEAPPLE PRACTICE](https://pnpl.site)

Пока сайт тестируетс локально 🤫🤷‍♀️. Но скоро состоится деплой 💪✊🤩
14 changes: 14 additions & 0 deletions src/test/java/practice/pineapple/model/FeedbackPage.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
package practice.pineapple.model;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import practice.pineapple.model.base.BasePage;

public class FeedbackPage extends BasePage {

private final By HEDER_REVIEWS = By.xpath("//h1");

public FeedbackPage(WebDriver driver) {

super(driver);
}

public WebElement getHederReviews() {

return getDriver().findElement(HEDER_REVIEWS);
}

public String getTextHederReviews() {

return getText(getHederReviews());
}
}
26 changes: 21 additions & 5 deletions src/test/java/practice/pineapple/model/HomePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ public class HomePage extends BasePage {
private final By HEDER_ABOUT_THE_STUDIO = By.xpath(
"//section[@class='_about_ze3bk_1']/div/h1"
);

private final By ALL_HEDERS = By.xpath("//h1");
private final By LINK_TO_REVIEWS = By.xpath("//section/a[@href='/reviews']");


public HomePage(WebDriver driver) {
// ни чего своего делать не нужно, так как драйвер,который нам передадут нужно передать в конструктор BasePage
super(driver); //вызвать супер
// ни чего своего делать не нужно, так как драйвер,который нам передадут
// нужно передать в конструктор BasePage
super(driver);
}

public WebElement getHederAboutTheStudio() {
Expand All @@ -32,6 +33,19 @@ public List<WebElement> getAllHeaders() {
return getDriver().findElements(ALL_HEDERS);
}

public WebElement getLinkToReviews() throws InterruptedException {

WebElement link = getDriver().findElement(LINK_TO_REVIEWS);
Thread.sleep(5000);

return link;
}

public String getTextHederAboutTheStudio() {

return getText(getHederAboutTheStudio());
}

public List<String> getTextAllHeaders() {

List<String> allHeaders = new ArrayList<>();
Expand All @@ -43,8 +57,10 @@ public List<String> getTextAllHeaders() {
return allHeaders;
}

public String getTextHederAboutTheStudio() {
public FeedbackPage clickLinkToReviews() {

return getText(getHederAboutTheStudio());
getDriver().findElement(By.xpath("//section/a[@href='/reviews']/div/h6")).click();

return new FeedbackPage(getDriver());
}
}
28 changes: 28 additions & 0 deletions src/test/java/practice/pineapple/model/MainPage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package practice.pineapple.model;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import practice.pineapple.model.base.BasePage;

public class MainPage extends BasePage {

private final By MENU_REVIEWS = By.xpath("//nav/ul/li/a[@href='/reviews']");

public MainPage(WebDriver driver) {

super(driver);
}

public WebElement getMenuReviews() {

return getDriver().findElement(MENU_REVIEWS);
}

public FeedbackPage clickMenuReviews() {

getMenuReviews().click();

return new FeedbackPage(getDriver());
}
}
35 changes: 35 additions & 0 deletions src/test/java/practice/pineapple/tests/FeedbackTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package practice.pineapple.tests;

import org.testng.Assert;
import org.testng.annotations.Test;
import practice.pineapple.model.HomePage;
import practice.pineapple.model.MainPage;
import practice.pineapple.runner.order.BaseTest;

public class FeedbackTests extends BaseTest {

final String headerExpectedResult = "Отзывы";

@Test
public void testHederReviewsAfterNavigatingFromHomePage() throws InterruptedException {

openBaseURL();
String headerActualResult = new HomePage(getDriver())
.clickLinkToReviews()
.getTextHederReviews();

Assert.assertEquals(headerActualResult, headerExpectedResult);
}

@Test

public void testHederReviewsAfterNavigatingFromMenu() {

openBaseURL();
String headerActualResult = new MainPage(getDriver())
.clickMenuReviews()
.getTextHederReviews();

Assert.assertEquals(headerActualResult, headerExpectedResult);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.Arrays;
import java.util.List;

public class HomePageTests extends BaseTest {
public class HomeTests extends BaseTest {

@Test
public void testHeaderAbout() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package practice.pineapple.tests.main;

import practice.pineapple.runner.order.BaseTest;

public class MainHeaderTests extends BaseTest {


}

0 comments on commit 0b6f57f

Please sign in to comment.