WIP: Zamaldinova #15

Closed
AlmiraZ wants to merge 4 commits from Zamaldinova into master
25 changed files with 912 additions and 0 deletions

35
Zamaldinova/pom.xml Normal file
View File

@ -0,0 +1,35 @@
<?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>
<groupId>project_testing</groupId>
<artifactId>project_testing</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,38 @@
package ru.sports.context;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import java.util.HashMap;
import java.util.Map;
public class ChromeContext extends Context {
private final static String WINDOWS_DRIVER = "chromedriver.exe";
private final static String LINUX_DRIVER = "chromedriver";
private final static String DRIVER_TYPE = "webdriver.chrome.driver";
@Override
protected void createDriver() {
// driver = new ChromeDriver();
ChromeOptions options = new ChromeOptions();
Map<String, Object> prefs = new HashMap<String, Object>();
tmpPath = System.getProperty("user.dir") + "/src/main/resources/downloads/";
prefs.put("download.default_directory", tmpPath);
//prefs.put("plugins.always_open_pdf_externally", true);
options.setExperimentalOption("prefs",prefs);
driver = new ChromeDriver(options);
}
@Override
protected String getDriverExecutable(boolean isWindows) {
return isWindows ? WINDOWS_DRIVER : LINUX_DRIVER;
}
@Override
protected String getDriverType() {
return DRIVER_TYPE;
}
}

View File

@ -0,0 +1,44 @@
package ru.sports.context;
import org.openqa.selenium.WebDriver;
import java.util.concurrent.TimeUnit;
public abstract class Context {
private final static String DRIVER_LOCATION = "drivers/%s";
protected WebDriver driver;
protected String tmpPath;
public WebDriver getDriver() {
if (driver != null) {
return driver;
}
throw new IllegalStateException("WebDriver is not initialized");
}
public void start() {
System.setProperty(getDriverType(), getDriverExecutablePath());
createDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
}
public void close() {
driver.quit();
}
protected abstract void createDriver();
protected abstract String getDriverType();
protected abstract String getDriverExecutable(boolean windows);
private String getDriverExecutablePath() {
return Context.class.getClassLoader().getResource(
String.format(DRIVER_LOCATION, getDriverExecutable(isWindows()))).getFile();
}
private boolean isWindows() {
return System.getProperty("os.name").toLowerCase().contains("windows");
}
}

View File

@ -0,0 +1,24 @@
package ru.sports.context;
import org.openqa.selenium.firefox.FirefoxDriver;
public class FirefoxContext extends Context {
private final static String WINDOWS_DRIVER = "geckodriver.exe";
private final static String LINUX_DRIVER = "geckodriver";
private final static String DRIVER_TYPE = "webdriver.gecko.driver";
@Override
protected void createDriver() {
driver = new FirefoxDriver();
}
@Override
protected String getDriverExecutable(boolean isWindows) {
return isWindows ? WINDOWS_DRIVER : LINUX_DRIVER;
}
@Override
protected String getDriverType() {
return DRIVER_TYPE;
}
}

View File

@ -0,0 +1,49 @@
package ru.sports.pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class AnotherLinks {
public WebDriver driver;
public AnotherLinks(WebDriver driver) {
this.driver = driver;
}
@FindBy(xpath = "//*[@id=\"branding-layout\"]/div[1]/div/div/div/div/aside/section[1]/div/div/a[1]")
private WebElement facebook;
@FindBy(xpath = "//*[@id=\"branding-layout\"]/div[1]/div/div/div/div/aside/section[1]/div/div/a[2]")
private WebElement VK;
@FindBy(xpath = "//*[@id=\"branding-layout\"]/div[1]/div/div/div/div/aside/section[1]/div/div/a[3]")
private WebElement Twitter;
public void facebookClick () { facebook.click(); }
public void VKClick () { VK.click(); }
public void TwitterClick () { Twitter.click(); }
public boolean assertFacebookClick() {
return driver.findElement(By.cssSelector("#blueBarDOMInspector > div > div > div > div.lfloat._ohe > a")).isDisplayed();
}
public boolean assertVKClick() {
return driver.findElement(By.cssSelector("#top_nav > div:nth-child(1) > a > div")).isDisplayed();
}
public boolean assertTwitterClick() {
return driver.findElement(By.cssSelector("#global-nav-home > a > span.Icon.Icon--bird.Icon--large")).isDisplayed();
}
}

View File

@ -0,0 +1,86 @@
package ru.sports.pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class ChangeLanguages {
public WebDriver driver;
public ChangeLanguages(WebDriver driver) {
this.driver = driver;
}
@FindBy(xpath = "//*[@id=\"branding-layout\"]/div[1]/header/nav[1]/div/div/div/span[2]")
private WebElement flag;
@FindBy(xpath = "//*[@id=\"branding-layout\"]/div[1]/header/nav[1]/div/div/ul/li[3]/a")
private WebElement Ukrain;
@FindBy(xpath = "//*[@id=\"branding-layout\"]/div[1]/header/nav[1]/div/div/ul/li[2]/a")
private WebElement Belarus;
public void flagClick() {
try {
Thread.sleep(20000);
} catch (InterruptedException e) {
e.printStackTrace();
}
flag.click();
}
public void UkrainClick() {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Ukrain.click();
}
public void BelarusClick() {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Belarus.click();
}
public boolean assertChangeUkrainLanguage() {
try {
Thread.sleep(20000);
} catch (InterruptedException e) {
e.printStackTrace();
}
try {
return driver.findElement(By.cssSelector("#branding-layout > " +
"div.page-layout > header > div.main-header__content-wrapper.main-wrap > a")).getText().indexOf("Ворскла") >= 0;
} catch (Exception e) {
return false;
}
}
public boolean assertChangeBelarusLanguage() {
try {
Thread.sleep(20000);
} catch (InterruptedException e) {
e.printStackTrace();
}
try {
return driver.findElement(By.cssSelector("#branding-layout > div.page-layout > div > div > aside > section:nth-child(7) > div > div.gadget__tournament-data > div > div:nth-child(1) > div.accordion__body >" +
" table > tbody > tr:nth-child(4) > td:nth-child(2) > a")).getText().indexOf("Динамо Минск") >= 0;
} catch (Exception e) {
return false;
}
}
}

View File

@ -0,0 +1,157 @@
package ru.sports.pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class FilterBy {
public WebDriver driver;
public FilterBy(WebDriver driver) {
this.driver = driver;
}
@FindBy(xpath = "//*[@id=\"branding-layout\"]/div[1]/div/div/div/div/aside/section[3]/div/form/div/label[1]/select")
private WebElement typeOfSport;
@FindBy(xpath = "//*[@id=\"branding-layout\"]/div[1]/div/div/div/div/aside/section[3]/div/form/div/label[1]/select/option[2]")
private WebElement football;
@FindBy(css = "#branding-layout > div.page-layout > div > div > div > div > aside > " +
"section:nth-child(3) > div > form > div > label:nth-child(2) > select")
private WebElement tourneer;
@FindBy(xpath = "//*[@id=\"branding-layout\"]/div[1]/div/div/div/div/aside/section[3]/div/form/div/label[2]/select/option[2]")
private WebElement leagueOfNation;
@FindBy(xpath = "//*[@id=\"branding-layout\"]/div[1]/div/div/div/div/aside/section[3]/div/form/div/label[3]/select")
private WebElement comand;
@FindBy(xpath = "//*[@id=\"branding-layout\"]/div[1]/div/div/div/div/aside/section[3]/div/form/div/label[3]/select/option[2]")
private WebElement Austria;
@FindBy(xpath = "//*[@id=\"branding-layout\"]/div[1]/div/div/div/div/aside/section[3]/div/form/label/input")
private WebElement Parameters;
@FindBy(xpath = "//*[@id=\"branding-layout\"]/div[1]/div/div/div/div/aside/section[16]/div/div[1]/label/select")
private WebElement selectTypeOfSport;
@FindBy(xpath = "//*[@id=\"branding-layout\"]/div[1]/div/div/div/div/aside/section[16]/div/div[1]/label/select/option[15]")
private WebElement Baseball;
@FindBy(xpath = "//*[@id=\"branding-layout\"]/div[1]/div/div/aside/section[1]/div/div[1]/form/select")
private WebElement Type;
@FindBy(xpath = "//*[@id=\"branding-layout\"]/div[1]/div/div/aside/section[1]/div/div[1]/form/select/option[12]")
private WebElement Turkey;
public void typeOfSportClick() {
typeOfSport.click();
}
public void footballClick() {
football.click();
}
public void tourneerClick() {
tourneer.click();
}
public void leagueOfNationClick() {
leagueOfNation.click();
}
public void comandClick() {
comand.click();
}
public void AustriaClick() {
Austria.click();
}
public void saveParametersClick() {
Parameters.click();
}
public void selectTypeOfSportClick() {
selectTypeOfSport.click();
}
public void BaseballClick() {
Baseball.click();
}
public void selectTypeClick() {
Type.click();
}
public void TurkeyClick() {
Turkey.click();
}
public boolean AssertSelectTypeOfSport() {
return driver.findElement(By.cssSelector("#branding-layout > div.page-layout > div > div > div > div > aside > " +
"section:nth-child(3) > div > form > div > label:nth-child(2) > select")).isDisplayed();
}
public boolean AssertTourneer() {
return driver.findElement(By.cssSelector("#branding-layout > div.page-layout > div > div > div > div > aside > section:nth-child(3)" +
" > div > form > div > label:nth-child(3) > select")).isDisplayed();
}
public boolean AssertComand() {
return driver.findElement(By.cssSelector("#branding-layout > div.page-layout > div > div > div > div >" +
" aside > section:nth-child(3) > div > form > label > input")).isDisplayed();
}
public boolean AssertUseFilterForNewsOfMyComand() {
try {
return driver.findElement(By.cssSelector("#branding-layout > div.page-layout > div > div > div > div " +
"> aside > section:nth-child(3) > div > div > ul > li > a")).getText().indexOf("Жеребьевка Евро-2020. Россия сыграет с Бельгией, Шотландией, Кипром, Казахстаном и Сан-Марино") >= 0;
}
catch (Exception e)
{
return false;
}
}
public boolean AssertUseFilterForNewsFromUsers() {
try {
return driver.findElement(By.cssSelector("#branding-layout > div.page-layout > div > div > div > div > aside > section:nth-child(16) > div > div.users-news__tabs.tabs_state_horizontal.tabs.tabs_animate.tabs_animate_horizontal-slide > div.tabs__body >" +
" div.users-news__tabs-panel.users-news__top-panel.tabs__panel.tabs__panel_active " +
"> ul:nth-child(2) > li > a")).getText().indexOf("МЛБ. Определились все участники плей-офф") >= 0;
}
catch (Exception e)
{
return false;
}
}
public boolean AssertUseFilterForStatistics() {
try {
return driver.findElement(By.cssSelector("#branding-layout > div.page-layout > div > div > aside > section:nth-child(6) > div > div.gadget__tournament-data > div > div:nth-child(1)" +
" >div.accordion__body > table > tbody > tr:nth-child(2) > td:nth-child(2) > a")).getText().indexOf("Истанбул") >= 0;
}
catch (Exception e)
{
return false;
}
}
}

View File

@ -0,0 +1,112 @@
package ru.sports.pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;
public class MainPage {
public static WebDriver driver;
public MainPage(WebDriver driver) {
this.driver = driver;
}
@FindBy(css = "#branding-layout > div.page-layout > header > nav.main-menu.main-menu_type_second.main-wrap"
+" > ul > li.main-menu__item.main-menu__item-basketball > a")
private WebElement SubmenuElement;
@FindBy(css = "#branding-layout > div.page-layout > header > nav.main-menu.main-menu_type_second.main-wrap > ul"
+" > li.main-menu__item.main-menu__item-basketball > div > ul:nth-child(1) > li:nth-child(3) > a")
private WebElement Submenu;
@FindBy(css = "#branding-layout > div.page-layout > header > nav.main-menu.main-menu_type_second.main-wrap"
+" > ul > li.main-menu__item.main-menu__item-biathlon > a")
private WebElement MainMenuElement;
@FindBy(css = "body > div.user-panel.user-panel--new.js-active.user-panel_state_loaded"
+" > div > div > a.user-panel__logo > svg > use")
private WebElement Logo;
@FindBy(css = "#branding-layout > div.page-layout > div > aside:nth-child(1) > section > article > a > img")
private WebElement Banner;
@FindBy(css = "#branding-layout > div.page-layout > div > aside:nth-child(1) > div.js-active.accordion > div >"
+" div:nth-child(1) > div.accordion__body > ul > li:nth-child(1) >"
+" div.teaser-event__board.clearfix.js-popup-match_handle > div:nth-child(3) > a")
private WebElement Match;
@FindBy(css = "#branding-layout > div.page-layout > footer > div.main-footer__lists-line.main-wrap.clearfix" +
" > dl.main-footer__list.main-footer__list_impressum.list-reset > dd:nth-child(4) > a)")
private WebElement Contacts;
public void clickSubmenu() {
Actions action = new Actions(driver);
action.moveToElement(SubmenuElement).perform();
Submenu.click();
}
public void clickMainMenu() {
MainMenuElement.click();
}
public void clickLogo() {
Logo.click();
}
public void clickBanner() {
Banner.click();
}
public void clickOnMatch() {
Match.click();
}
public void clickOnContacts() {
Contacts.click();
}
public boolean isPageDisplaySubmenu() {
return driver.findElement(By.cssSelector("#branding-layout > div > div.sportsru.sportsru--d > header" +
" > div > a.main-header__logo-link-nba")).isDisplayed();
}
public boolean isPageDisplayMainMenu() {
return driver.findElement(By.cssSelector("#branding-layout > div.page-layout > "
+"div > div > div > div > aside > section:nth-child(1) > h3 > a")).isDisplayed();
}
public boolean isPageDisplayMainPage() {
return driver.findElement(By.cssSelector("#branding-layout > div.page-layout > div > div > div >"
+" div > aside > section:nth-child(1) > h3 > a")).isDisplayed();
}
public boolean isPageDisplayBanner() {
return driver.findElement(By.cssSelector("#branding-layout > div.page-layout > div >"
+" div.columns-layout.main-wrap > aside > section > h3")).isDisplayed();
}
public boolean isPageDisplayDetailsOfMatch() {
return driver.findElement(By.cssSelector("#branding-layout > div > div.contentLayout.js-active > div.box >"
+" div.title-page.bordered > h1")).isDisplayed();
}
public boolean isPageDisplayContacts() {
return driver.findElement(By.cssSelector("#branding-layout > div.page-layout > " +
"div > div.columns-layout.main-wrap > main > div > h1 > a")).isDisplayed();
}
}

View File

@ -0,0 +1,46 @@
package ru.sports.pages;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import java.util.List;
public class Search {
public WebDriver driver;
public Search(WebDriver driver) {
this.driver = driver;
}
@FindBy(css = "#branding-layout > div.page-layout > header > " +
"div.main-header__content-wrapper.main-wrap > div.main-header__search-block > div > form > input")
private WebElement searchField;
@FindBy(css = "#branding-layout > div.page-layout > header > div.main-header__content-wrapper.main-wrap" +
" > div.main-header__search-block > div > form > button > span")
private WebElement searchButton;
@FindBy(css = ".page-result-search .list-group-item")
private List<WebElement> listResultSearch;
public void inputSearchField(String text) {
searchField.click();
searchField.sendKeys(text);
}
public void clickSearchingButton() {
searchButton.click();
}
public boolean checkSearch(String strSearch) {
boolean checkSearch = false;
int count = listResultSearch.size();
for (int i = 0; i < count - 1; i++) {
if (listResultSearch.get(i).getText().contains(strSearch))
checkSearch = true;
}
return true;
}
}

View File

@ -0,0 +1,53 @@
package ru.sports.tests;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.support.PageFactory;
import ru.sports.context.ChromeContext;
import ru.sports.context.Context;
import ru.sports.pages.AnotherLinks;
public class AnotherlinksTest {
private final static String APP_URL = "https://www.sports.ru/";
private static Context context;
@BeforeClass
public static void setup() {
context = new ChromeContext();
context.start();
}
@AfterClass
public static void quit() {
context.close();
}
@Test
public void facebookClub() {
context.getDriver().get(APP_URL);
AnotherLinks anotherLinks = PageFactory.initElements(context.getDriver(), AnotherLinks.class);
anotherLinks.facebookClick();
Assert.assertTrue(anotherLinks.assertFacebookClick());
}
@Test
public void VKClub() {
context.getDriver().get(APP_URL);
AnotherLinks anotherLinks = PageFactory.initElements(context.getDriver(), AnotherLinks.class);
anotherLinks.VKClick();
Assert.assertTrue(anotherLinks.assertVKClick());
}
@Test
public void TwitterClub() {
context.getDriver().get(APP_URL);
AnotherLinks anotherLinks = PageFactory.initElements(context.getDriver(), AnotherLinks.class);
anotherLinks.TwitterClick();
Assert.assertTrue(anotherLinks.assertTwitterClick());
}
}

View File

@ -0,0 +1,45 @@
package ru.sports.tests;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.support.PageFactory;
import ru.sports.context.ChromeContext;
import ru.sports.context.Context;
import ru.sports.pages.ChangeLanguages;
public class ChangeLanguageTest {
private final static String APP_URL = "https://www.sports.ru/";
private static Context context;
@BeforeClass
public static void setup() {
context = new ChromeContext();
context.start();
}
@AfterClass
public static void quit() {
context.close();
}
@Test
public void checkChangeUkrainlanguage() {
context.getDriver().get(APP_URL);
ChangeLanguages changeLanguage = PageFactory.initElements(context.getDriver(), ChangeLanguages.class);
changeLanguage.flagClick();
changeLanguage.UkrainClick();
Assert.assertTrue(changeLanguage.assertChangeUkrainLanguage());
}
@Test
public void checkChangeBelaruslanguage() {
context.getDriver().get(APP_URL);
ChangeLanguages changeLanguage = PageFactory.initElements(context.getDriver(), ChangeLanguages.class);
changeLanguage.flagClick();
changeLanguage.BelarusClick();
Assert.assertTrue(changeLanguage.assertChangeBelarusLanguage());
}
}

View File

@ -0,0 +1,100 @@
package ru.sports.tests;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.support.PageFactory;
import ru.sports.context.ChromeContext;
import ru.sports.context.Context;
import ru.sports.pages.FilterBy;
public class FilterByTest {
private final static String APP_URL = "https://www.sports.ru/";
private static Context context;
@BeforeClass
public static void setup() {
context = new ChromeContext();
context.start();
}
@AfterClass
public static void quit() {
context.close();
}
@Test
public void selectTypeOfSport() {
context.getDriver().get(APP_URL);
FilterBy filterBy = PageFactory.initElements(context.getDriver(), FilterBy.class);
filterBy.typeOfSportClick();
filterBy.footballClick();
Assert.assertTrue(filterBy.AssertSelectTypeOfSport());
}
@Test
public void selectTourneer() {
context.getDriver().get(APP_URL);
FilterBy filterBy = PageFactory.initElements(context.getDriver(), FilterBy.class);
filterBy.typeOfSportClick();
filterBy.footballClick();
filterBy.typeOfSportClick();
filterBy.tourneerClick();
filterBy.leagueOfNationClick();
Assert.assertTrue(filterBy.AssertTourneer());
}
@Test
public void selectComand() {
context.getDriver().get(APP_URL);
FilterBy filterBy = PageFactory.initElements(context.getDriver(), FilterBy.class);
filterBy.typeOfSportClick();
filterBy.footballClick();
filterBy.typeOfSportClick();
filterBy.tourneerClick();
filterBy.leagueOfNationClick();
filterBy.tourneerClick();
filterBy.comandClick();
filterBy.AustriaClick();
Assert.assertTrue(filterBy.AssertComand());
}
@Test
public void useFilterForNewsOfMyComand() {
context.getDriver().get(APP_URL);
FilterBy filterBy = PageFactory.initElements(context.getDriver(), FilterBy.class);
filterBy.typeOfSportClick();
filterBy.footballClick();
filterBy.typeOfSportClick();
filterBy.tourneerClick();
filterBy.leagueOfNationClick();
filterBy.tourneerClick();
filterBy.comandClick();
filterBy.AustriaClick();
filterBy.comandClick();
filterBy.saveParametersClick();
Assert.assertTrue(filterBy.AssertUseFilterForNewsOfMyComand());
}
@Test
public void useFilterForNewsFromUsers() {
context.getDriver().get(APP_URL);
FilterBy filterBy = PageFactory.initElements(context.getDriver(), FilterBy.class);
filterBy.selectTypeOfSportClick();
filterBy.BaseballClick();
Assert.assertTrue(filterBy.AssertUseFilterForNewsFromUsers());
}
@Test
public void useFilterForStatistics() {
context.getDriver().get(APP_URL);
FilterBy filterBy = PageFactory.initElements(context.getDriver(), FilterBy.class);
filterBy.selectTypeClick();
filterBy.TurkeyClick();
Assert.assertTrue(filterBy.AssertUseFilterForStatistics());
}
}

View File

@ -0,0 +1,75 @@
package ru.sports.tests;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.support.PageFactory;
import ru.sports.context.ChromeContext;
import ru.sports.context.Context;
import ru.sports.pages.MainPage;
public class MainPageTest {
private final static String APP_URL = "https://www.sports.ru/";
private static Context context;
@BeforeClass
public static void setup() {
context = new ChromeContext();
context.start();
}
@AfterClass
public static void quit() {
context.close();
}
@Test
public void SubmenuNavigationTest() {
context.getDriver().get(APP_URL);
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
page.clickSubmenu();
Assert.assertTrue(page.isPageDisplaySubmenu());
}
@Test
public void MainMenuNavigationTest() {
context.getDriver().get(APP_URL);
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
page.clickMainMenu();
Assert.assertTrue(page.isPageDisplayMainMenu());
}
@Test
public void NavigationByLogoTest() {
context.getDriver().get(APP_URL);
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
page.clickMainMenu();
page.clickLogo();
Assert.assertTrue(page.isPageDisplayMainPage());
}
@Test
public void NavigationByBanner() {
context.getDriver().get(APP_URL);
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
page.clickBanner();
Assert.assertTrue(page.isPageDisplayBanner());
}
@Test
public void TableOfMatchesNavigation() {
context.getDriver().get(APP_URL);
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
page.clickOnMatch();
Assert.assertTrue(page.isPageDisplayDetailsOfMatch());
}
@Test
public void FooterNavigation() {
context.getDriver().get(APP_URL);
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
page.clickOnContacts();
Assert.assertTrue(page.isPageDisplayContacts());
}
}

View File

@ -0,0 +1,48 @@
package ru.sports.tests;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.support.PageFactory;
import ru.sports.context.ChromeContext;
import ru.sports.context.Context;
import ru.sports.pages.Search;
public class SearchingTest {
private final static String APP_URL = "https://www.sports.ru/";
private static Context context;
String search1 = "Неймар";
String search2 = "123";
@BeforeClass
public static void setup() {
context = new ChromeContext();
context.start();
}
@AfterClass
public static void quit() {
context.close();
}
@Test
public void checkSearchingByKeyWords() {
context.getDriver().get(APP_URL);
Search search = PageFactory.initElements(context.getDriver(), Search.class);
search.inputSearchField(search1);
search.clickSearchingButton();
Assert.assertTrue(search.checkSearch(search1));
}
@Test
public void checkSearchingByNumb() {
context.getDriver().get(APP_URL);
Search search = PageFactory.initElements(context.getDriver(), Search.class);
search.inputSearchField(search2);
search.clickSearchingButton();
Assert.assertTrue(search.checkSearch(search2));
}
}