Compare commits

...

17 Commits

Author SHA1 Message Date
Екатерина
ecb3703853 Update Context.java 2018-12-08 21:30:33 +00:00
Екатерина
ff9d57a5c6 Update MultiMedia.java 2018-12-08 21:21:48 +00:00
Екатерина
53546b1ae7 Update MultiMediaTest.java 2018-12-08 21:20:57 +00:00
Екатерина
4d3f85fab9 Update SortBy.java 2018-12-08 20:58:31 +00:00
Екатерина
307e02ad68 Update Search.java 2018-12-08 20:57:58 +00:00
Екатерина
119520f2aa Update MainPage.java 2018-12-08 20:57:23 +00:00
Екатерина
3b964d787e Update FilterBy.java 2018-12-08 20:54:56 +00:00
Екатерина
8ab0bf1374 Update ChangeLanguages.java 2018-12-08 20:54:00 +00:00
Екатерина
f0e42847a5 Update AnotherlinksTest.java 2018-12-08 20:51:06 +00:00
Екатерина
709ac331ba Update ChangeLanguageTest.java 2018-12-08 20:50:23 +00:00
Екатерина
bd0b9f5479 Update FilterByTest.java 2018-12-08 20:49:41 +00:00
Екатерина
26da0b49b8 Update MainPageTest.java 2018-12-08 20:48:35 +00:00
Екатерина
3cff287216 Update MainPageTest.java 2018-12-08 20:46:45 +00:00
Екатерина
6c97e12bd2 Update SearchingTest.java 2018-12-08 20:44:48 +00:00
Екатерина
72643afa78 Update SortByTest.java 2018-12-08 20:43:44 +00:00
Екатерина
065d590693 Update AnotherLinks.java 2018-12-08 20:41:23 +00:00
Rukavishnikova
653dc6fd71 InitialCommit 2018-11-20 02:41:01 +04:00
16 changed files with 882 additions and 2 deletions

35
Rukavishnikova/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>

View File

@ -0,0 +1,51 @@
package ru.oriflame.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(className = "shipping-info-link")
private WebElement form;
@FindBy(linkText = "Контакты Сервисных Центров Орифлэйм")
private WebElement contactsServicesCenters;
@FindBy(css = "nav.w-grid > div:nth-child(1) > div:nth-child(1) > a:nth-child(1)")
private WebElement oriLogo;
public void formClicking () { form.click(); }
public void clickingContactsServicesCenters() {
contactsServicesCenters.click();
}
public void clickingOrifalemLogo() { oriLogo.click(); }
public boolean assertMainMenu() { return driver.findElement(By.cssSelector("#main > div")).isDisplayed(); }
public boolean assertContactsServicesCenters() {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return driver.findElement(By.cssSelector("body > div.w-grid")).isDisplayed();
}
public boolean assertFormClick() {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return driver.findElement(By.cssSelector("#pdp-shipping-popup")).isDisplayed();
}
}

View File

@ -0,0 +1,45 @@
package ru.oriflame.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=\"accordion-2\"]")
private WebElement asiaButton;
@FindBy(xpath = "//*[@id=\"sect2\"]/ul[1]/li[1]/a/span")
private WebElement chinaLink;
public void asiaButtonClicking() {
asiaButton.click();
}
public void chinaLinking() {
chinaLink.click();
}
public boolean assertChangelanguag() {
try {
Thread.sleep(15000);
} catch (InterruptedException e) {
e.printStackTrace();
}
try {
return driver.findElement(By.cssSelector("body > header > div > div.ui-sticky-bar.js-sticky-bar > div.w-sticky-bar-list.clearfix > ul > li.catalogue.left.only-for-desktop-size > a")).getText().indexOf("产品目录") >= 0;
}
catch (Exception e)
{
return false;
}
}
}

View File

@ -0,0 +1,167 @@
package ru.oriflame.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=\"primary-navigation\"]/ul/li[2]/a")
private WebElement face;
@FindBy(xpath = "//*[@id=\"main\"]/div[5]/div/section/div[1]/div/div/div[1]/div[1]")
private WebElement openedFilterrBy;
@FindBy(xpath = "//*[@id=\"main\"]/div[5]/div/section/div[1]/div/div/div[3]/form/ul/li[2]/h3")
private WebElement filetrByIndications;
@FindBy(xpath = "//*[@id=\"main\"]/div[5]/div/section/div[1]/div/div/div[3]/form/ul/li[5]/h3")
private WebElement filterByAge;
@FindBy(xpath = "//*[@id=\"main\"]/div[5]/div/section/div[1]/div/div/div[3]/form/ul/li[3]/h3")
private WebElement filterByAdvantage;
@FindBy(xpath = "//*[@id=\"main\"]/div[5]/div/section/div[1]/div/div/div[3]/form/ul/li[6]/h3")
private WebElement filterByBrand;
@FindBy(xpath = "//*[@id=\"main\"]/div[5]/div/section/div[1]/div/div/div[3]/form/ul/li[5]/div/ul[1]/li[1]/a")
private WebElement age12;
@FindBy(xpath = "//*[@id=\"main\"]/div[5]/div/section/div[1]/div/div/div[3]/form/ul/li[3]/div/ul[1]/li[1]/a")
private WebElement anti;
public void faceClick() {
face.click();
}
public void FilterByAdvantageAnti() {
try {
Thread.sleep(15000);
} catch (InterruptedException e) {
e.printStackTrace();
}
anti.click();
}
public void filterByAge12() {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
age12.click();
}
public void openingFilterBy() {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
openedFilterrBy.click();
}
public void clickingFilterByIndications() {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
filetrByIndications.click(); }
public void clickingFilterByAge() {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
filterByAge.click();
}
public void clickingFilterByAdvantage () {
try {
Thread.sleep(15000);
} catch (InterruptedException e) {
e.printStackTrace();
}
filterByAdvantage.click();
}
public void clickingFilterByBrand() {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
filterByBrand.click();
}
public boolean AssertFilterBy() {
return driver.findElement(By.cssSelector("#main > div:nth-child(5) > div > section > div.w-filter-bar > div > div > div.w-filter-box.w-filter-box-no-css.fixed > form")).isDisplayed();
}
public boolean AssertByIndications() {
return driver.findElement(By.cssSelector("#main > div:nth-child(5) > div > section > div.w-filter-bar > div > div > div.w-filter-box.w-filter-box-no-css.fixed > form > ul > li.facet.row.g-all.opened > div > ul:nth-child(1)")).isDisplayed();
}
public boolean assertFilterByBrand() {
return driver.findElement(By.cssSelector("li.facet:nth-child(6) > div:nth-child(2) > ul:nth-child(1)")).isDisplayed();
}
public boolean assertFilterByAdvantage() {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return driver.findElement(By.cssSelector("#main > div:nth-child(5) > div > section > div.w-filter-bar > div > div > div.w-filter-box.w-filter-box-no-css.fixed > form > ul > li.facet.row.g-all.opened > div > ul:nth-child(1)")).isDisplayed();
}
public boolean assertFilterByAge() {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
try {
return driver.findElement(By.cssSelector("#main > div:nth-child(5) > div > section > div.w-filter-bar > div > div > div.w-filtering-info.g-all > div.w-filtered-facets > span")).getText().indexOf("12+") >= 0;
}
catch (Exception e)
{
return false;
}
}
public boolean assertFilterByAdvantageAnti() {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
try {
return driver.findElement(By.cssSelector("#main > div:nth-child(5) > div > section > div.w-filter-bar > div > div > div.w-filtering-info.g-all > div.w-filtered-facets > span")).getText().indexOf("Антивозрастной Уход") >= 0;
}
catch (Exception e)
{
return false;
}
}
}

View File

@ -0,0 +1,66 @@
package ru.oriflame.pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class MainPage {
public static WebDriver driver;
public MainPage(WebDriver driver) {
this.driver = driver;
}
@FindBy(xpath = "//*[@id=\"primary-navigation\"]/ul/li[2]/a")
private WebElement face;
@FindBy(css = "body > header > div > div.ui-header-bar > nav > div > div.ui-logo > a > span > svg")
private WebElement main;
@FindBy(css = "body > header > div > div.ui-sticky-bar.js-sticky-bar > div.w-sticky-bar-list.clearfix > ul > li:nth-child(3) > a")
private WebElement registr;
@FindBy(css = "body > footer > div.ui-standard-footer.w-grid > ul > li:nth-child(3) > a")
private WebElement podval;
@FindBy(css = "#hero-promo-slider > div.rsOverflow > div > div.rsSlide.rsActiveSlide > div > article > a > div.image-A1 > img")
private WebElement banner;
@FindBy(css = "#main > div:nth-child(5) > div > section > section > a:nth-child(1) > div.figure > img")
private WebElement product;
public void faceClick() { face.click(); }
public void mainClick() { main.click(); }
public void registrClick() { registr.click(); }
public void podvalClick() {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
podval.click();
}
public void bannerClick() { banner.click(); }
public void productClick() { product.click(); }
public static boolean assertHeightMenu() { return driver.findElement(By.cssSelector("#main > div.w-top-area-banner.category-skincare.with-background.with-img > div.ui-banner-image > img")).isDisplayed(); }
public static boolean assertBanner() { return driver.findElement(By.cssSelector("#facets-search-results > section")).isDisplayed(); }
public static boolean assertProduct() { return driver.findElement(By.cssSelector("#pdp-image-slider > div.rsOverflow > div > div:nth-child(1) > div > img")).isDisplayed(); }
public static boolean assertRegister() { return driver.findElement(By.cssSelector("#main > div.w-content > div > div > p")).isDisplayed(); }
public static boolean assertDown() {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}return driver.findElement(By.cssSelector("#main > div > div > div")).isDisplayed(); }
}

View File

@ -0,0 +1,27 @@
package ru.oriflame.pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class MultiMedia {
public WebDriver driver;
public MultiMedia(WebDriver driver) {
this.driver = driver;
}
@FindBy(xpath = "//*[@id=\"block-block-5\"]/p/a")
private WebElement playVideo;
public void playVideoElement() {
playVideo.click();
}
public boolean assertVideoPlay() {
return driver.findElement(By.cssSelector("body > div.mfp-wrap.mfp-close-btn-in.mfp-auto-cursor.mfp-ready > div > div > div > button")).isDisplayed();
}
}

View File

@ -0,0 +1,44 @@
package ru.oriflame.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 = "#global-search")
private WebElement searchField;
@FindBy(css = "#form-search > fieldset > button")
private WebElement searchButton;
@FindBy(css = "#main > div.w-content.ui-search-content.mode-products-search")
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,65 @@
package ru.oriflame.pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class SortBy {
public WebDriver driver;
public SortBy(WebDriver driver) {
this.driver = driver;
}
@FindBy(xpath = "//*[@id=\"primary-navigation\"]/ul/li[2]/a")
private WebElement face;
@FindBy(xpath = "//*[@id=\"main\"]/div[5]/div/section/div[1]/div/div/div[1]/div[2]")
private WebElement sortingBy;
@FindBy(xpath = "//*[@id=\"main\"]/div[5]/div/section/div[1]/div/div/div[2]/ul/li[2]/span/label")
private WebElement byPopular;
public void faceClick() {
face.click();
}
public void sortByClick() {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
sortingBy.click();
}
public void sortByPopularClick() {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
byPopular.click();
}
public boolean assertShowMenuSort() {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return driver.findElement(By.cssSelector("#main > div:nth-child(5) > div > section > div.w-filter-bar > div > div > div.w-sort-box.fixed > ul")).isDisplayed();
}
public boolean assertcheckLinkBySort() {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return driver.findElement(By.cssSelector("#main > div:nth-child(5) > div > section > div.w-filter-bar > div > div > div.w-filtering-info.g-all > div.w-filtered-facets > span")).getText().indexOf("популярности") >= 0;
}
}

View File

@ -0,0 +1,53 @@
package ru.oriflame.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.oriflame.context.ChromeContext;
import ru.oriflame.context.Context;
import ru.oriflame.pages.AnotherLinks;
public class AnotherlinksTest {
private final static String APP_URL = "https://www.oriflame.ru/products/product?code=32418";
private static Context context;
@BeforeClass
public static void setup() {
context = new ChromeContext();
context.start();
}
@AfterClass
public static void quit() {
context.close();
}
@Test
public void checkFormClick() {
context.getDriver().get(APP_URL);
AnotherLinks anotherLinks = PageFactory.initElements(context.getDriver(), AnotherLinks.class);
anotherLinks.formClicking();
Assert.assertTrue(anotherLinks.assertFormClick());
}
@Test
public void checkContactsSCClick() {
context.getDriver().get(APP_URL);
AnotherLinks anotherLinks = PageFactory.initElements(context.getDriver(), AnotherLinks.class);
anotherLinks.formClicking();
anotherLinks.clickingContactsServicesCenters();
Assert.assertTrue(anotherLinks.assertContactsServicesCenters());
}
@Test
public void checkOriflameLogoClickingFromMainPage() {
context.getDriver().get(APP_URL);
AnotherLinks anotherLinks = PageFactory.initElements(context.getDriver(), AnotherLinks.class);
anotherLinks.clickingOrifalemLogo();
Assert.assertTrue(anotherLinks.assertMainMenu());
}
}

View File

@ -0,0 +1,39 @@
package ru.oriflame.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.oriflame.context.ChromeContext;
import ru.oriflame.context.Context;
import ru.oriflame.pages.ChangeLanguages;
import ru.oriflame.pages.MainPage;
public class ChangeLanguageTest {
private final static String APP_URL = "https://www.oriflame.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 checkChangelanguage() {
context.getDriver().get(APP_URL);
MainPage mainPage = PageFactory.initElements(context.getDriver(), MainPage.class);
mainPage.podvalClick();
ChangeLanguages changeLanguage = PageFactory.initElements(context.getDriver(), ChangeLanguages.class);
changeLanguage.asiaButtonClicking();
changeLanguage.chinaLinking();
Assert.assertTrue(changeLanguage.assertChangelanguag());
}
}

View File

@ -0,0 +1,88 @@
package ru.oriflame.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.oriflame.context.ChromeContext;
import ru.oriflame.context.Context;
import ru.oriflame.pages.FilterBy;
public class FilterByTest {
private final static String APP_URL = "https://www.oriflame.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 checkOpenFilters() {
context.getDriver().get(APP_URL);
FilterBy filterBy = PageFactory.initElements(context.getDriver(), FilterBy.class);
filterBy.faceClick();
filterBy.openingFilterBy();
filterBy.AssertFilterBy();
}
@Test
public void checkFilterByIndications() {
context.getDriver().get(APP_URL);
FilterBy filterBy = PageFactory.initElements(context.getDriver(), FilterBy.class);
filterBy.faceClick();
filterBy.openingFilterBy();
filterBy.clickingFilterByIndications();
filterBy.AssertByIndications();
}
@Test
public void checkFilterByBrand() {
context.getDriver().get(APP_URL);
FilterBy filterBy = PageFactory.initElements(context.getDriver(), FilterBy.class);
filterBy.faceClick();
filterBy.openingFilterBy();
filterBy.clickingFilterByBrand();
Assert.assertTrue(filterBy.assertFilterByBrand());
}
@Test
public void checkFilterByAge() {
context.getDriver().get(APP_URL);
FilterBy filterBy = PageFactory.initElements(context.getDriver(), FilterBy.class);
filterBy.faceClick();
filterBy.openingFilterBy();
filterBy.clickingFilterByAge();
filterBy.filterByAge12();
Assert.assertTrue(filterBy.assertFilterByAge());
}
@Test
public void checkFilterByAdvantage() {
context.getDriver().get(APP_URL);
FilterBy filterBy = PageFactory.initElements(context.getDriver(), FilterBy.class);
filterBy.faceClick();
filterBy.openingFilterBy();
filterBy.clickingFilterByAdvantage();
Assert.assertTrue(filterBy.assertFilterByAdvantage());
}
@Test
public void checkFilterByAdvantageOsv() {
context.getDriver().get(APP_URL);
FilterBy filterBy = PageFactory.initElements(context.getDriver(), FilterBy.class);
filterBy.faceClick();
filterBy.openingFilterBy();
filterBy.clickingFilterByAdvantage();
filterBy.FilterByAdvantageAnti();
Assert.assertTrue(filterBy.assertFilterByAdvantageAnti());
}
}

View File

@ -0,0 +1,70 @@
package ru.oriflame.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.oriflame.context.ChromeContext;
import ru.oriflame.context.Context;
import ru.oriflame.pages.MainPage;
public class MainPageTest {
private final static String APP_URL = "https://www.oriflame.ru/products/product?code=32418";
private static Context context;
@BeforeClass
public static void setup() {
context = new ChromeContext();
context.start();
}
@AfterClass
public static void quit() {
context.close();
}
@Test
public void checkHeightMenu() {
context.getDriver().get(APP_URL);
MainPage mainPage = PageFactory.initElements(context.getDriver(), MainPage.class);
mainPage.faceClick();
Assert.assertTrue(MainPage.assertHeightMenu());
}
@Test
public void checkProfileCap() {
context.getDriver().get(APP_URL);
MainPage mainPage = PageFactory.initElements(context.getDriver(), MainPage.class);
mainPage.registrClick();
Assert.assertTrue(MainPage.assertRegister());
}
@Test
public void checkDown() {
context.getDriver().get(APP_URL);
MainPage mainPage = PageFactory.initElements(context.getDriver(), MainPage.class);
mainPage.mainClick();
mainPage.podvalClick();
Assert.assertTrue(MainPage.assertDown());
}
@Test
public void checkBasementLink() {
context.getDriver().get(APP_URL);
MainPage mainPage = PageFactory.initElements(context.getDriver(), MainPage.class);
mainPage.mainClick();
mainPage.bannerClick();
Assert.assertTrue(MainPage.assertBanner());
}
@Test
public void checkProduct() {
context.getDriver().get(APP_URL);
MainPage mainPage = PageFactory.initElements(context.getDriver(), MainPage.class);
mainPage.faceClick();
mainPage.productClick();
Assert.assertTrue(MainPage.assertProduct());
}
}

View File

@ -0,0 +1,35 @@
package ru.oriflame.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.oriflame.context.ChromeContext;
import ru.oriflame.context.Context;
import ru.oriflame.pages.MultiMedia;
public class MultiMediaTest {
private final static String APP_URL = "http://investors.oriflame.com/";
private static Context context;
@BeforeClass
public static void setup() {
context = new ChromeContext();
context.start();
}
@AfterClass
public static void quit() {
context.close();
}
@Test
public void checkVideoPlay() {
context.getDriver().get(APP_URL);
MultiMedia multiMedia = PageFactory.initElements(context.getDriver(), MultiMedia.class);
multiMedia.playVideoElement();
Assert.assertTrue(multiMedia.assertVideoPlay());
}
}

View File

@ -0,0 +1,48 @@
package ru.oriflame.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.oriflame.context.ChromeContext;
import ru.oriflame.context.Context;
import ru.oriflame.pages.Search;
public class SearchingTest {
private final static String APP_URL = "https://oriflame.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));
}
}

View File

@ -0,0 +1,46 @@
package ru.oriflame.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.oriflame.context.ChromeContext;
import ru.oriflame.context.Context;
import ru.oriflame.pages.SortBy;
public class SortByTest {
private final static String APP_URL = "https://www.oriflame.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 checkShowMenuSort() {
context.getDriver().get(APP_URL);
SortBy sortBy = PageFactory.initElements(context.getDriver(), SortBy.class);
sortBy.faceClick();
sortBy.sortByClick();
Assert.assertTrue(sortBy.assertShowMenuSort());
}
@Test
public void checkLinkBySort() {
context.getDriver().get(APP_URL);
SortBy sortBy = PageFactory.initElements(context.getDriver(), SortBy.class);
sortBy.faceClick();
sortBy.sortByClick();
sortBy.sortByPopularClick();
Assert.assertTrue(sortBy.assertcheckLinkBySort());
}
}

View File

@ -1,4 +1,4 @@
package context; package ru.oriflame.context;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver;
@ -7,6 +7,7 @@ import java.util.concurrent.TimeUnit;
public abstract class Context { public abstract class Context {
private final static String DRIVER_LOCATION = "drivers/%s"; private final static String DRIVER_LOCATION = "drivers/%s";
protected WebDriver driver; protected WebDriver driver;
protected String tmpPath;
public WebDriver getDriver() { public WebDriver getDriver() {
if (driver != null) { if (driver != null) {
@ -18,8 +19,8 @@ public abstract class Context {
public void start() { public void start() {
System.setProperty(getDriverType(), getDriverExecutablePath()); System.setProperty(getDriverType(), getDriverExecutablePath());
createDriver(); createDriver();
// это плохая инструкция для автотестов, т.к. лучше задавать для конкретного элемента или кейса
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
} }
public void close() { public void close() {