Edit tests

This commit is contained in:
Kochkaleva 2018-11-29 11:28:00 +04:00
parent e8b00cbe09
commit 6039438f6e
6 changed files with 123 additions and 13 deletions

View File

@ -72,4 +72,12 @@ public class Email {
public void logInButtonClick() { public void logInButtonClick() {
logInButton.click(); logInButton.click();
} }
public void logInButtonDisplayed() {
if (logInButton != null) {
} else {
throw new IllegalStateException("Element is missing, should be displayed");
}
}
} }

View File

@ -18,7 +18,7 @@ public class Navigation {
@FindBy(xpath = "/html/body/div[7]/div[1]/div/div[4]/div/a[1]") @FindBy(xpath = "/html/body/div[7]/div[1]/div/div[4]/div/a[1]")
private WebElement yesCityButton; private WebElement yesCityButton;
@FindBy(xpath = "//*[@id=\"cat_cat308680401\"]/a") @FindBy(id = "cat_cat308680401")
private WebElement saleLink; private WebElement saleLink;
@FindBy(xpath = "//*[@id=\"cat_cat308680401\"]/div/div/div/div/ul/li[1]/a") @FindBy(xpath = "//*[@id=\"cat_cat308680401\"]/div/div/div/div/ul/li[1]/a")
@ -30,6 +30,51 @@ public class Navigation {
@FindBy(xpath = "//*[@id=\"atg_store_footer\"]/div[3]/div/ul/li[2]/div[1]/div/a[2]") @FindBy(xpath = "//*[@id=\"atg_store_footer\"]/div[3]/div/ul/li[2]/div[1]/div/a[2]")
private WebElement socialElementLink; private WebElement socialElementLink;
@FindBy(xpath = "//*[@id=\"group\"]/div[1]/div[2]/div[2]/h2")
private WebElement pageName;
@FindBy(xpath = "//*[@id=\"atg_store_content\"]/div[2]/ul/li[1]")
private WebElement displayedPromo;
@FindBy(xpath = "//*[@id=\"atg_store_content\"]/div[2]/div[2]/div[1]/h1")
private WebElement mainTitle;
@FindBy(xpath = "//*[@id=\"atg_store_content\"]/div/div[1]/div/div[1]/a")
private WebElement womenSales;
public void womaneSalesLink() {
if (womenSales != null) {}
else {
throw new IllegalStateException("element is missing");
}
}
public void setMainTitle() {
String title = mainTitle.getAttribute("InnerText");
if (title.equals("Распродажа женской одежды O`STIN")) {
} else {
throw new IllegalStateException("something went wrong");
}
}
public void setDisplayedPromo() {
if (displayedPromo != null) {
} else {
throw new IllegalStateException("element is missing");
}
}
public void setPageName() {
String title = pageName.getAttribute("InnerText");
if (title.equals("O'STIN | ОСТИН")) {
} else {
throw new IllegalStateException("something went wrong");
}
}
private void setCurrentCity() { private void setCurrentCity() {
if (yesCityButton != null) { if (yesCityButton != null) {
yesCityButton.click(); yesCityButton.click();

View File

@ -53,6 +53,17 @@ public class Sort {
@FindBy(id = "atg_store_searchInput") @FindBy(id = "atg_store_searchInput")
private WebElement searchField; private WebElement searchField;
@FindBy(xpath = "//*[@id=\"atg_store_content\"]/div[2]/div[2]/div[3]/div/div/b[1]")
private WebElement searchingRequset;
public void setSearchingRequset() {
if (searchingRequset != null) {
} else {
throw new IllegalStateException(" this");
}
}
public static int random(int lowerBound, int upperBound) { public static int random(int lowerBound, int upperBound) {
return (lowerBound + (int) Math.round(Math.random() return (lowerBound + (int) Math.round(Math.random()
* (upperBound - lowerBound))); * (upperBound - lowerBound)));

View File

@ -48,7 +48,7 @@ public class EmailTests {
public void checkForLogIn() { public void checkForLogIn() {
boolean pass = false; boolean pass = false;
email.logInLinkCLick(); email.logInLinkCLick();
// В кавычках ниже заполнить данными //В кавычках ниже заполнить данными
email.fillFields("lkdlfr@mail.ru", "jhbhjbjbj"); email.fillFields("lkdlfr@mail.ru", "jhbhjbjbj");
email.logInButtonClick(); email.logInButtonClick();
try { try {
@ -56,17 +56,23 @@ public class EmailTests {
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
pass = true; pass = true;
} }
Assert.assertTrue("login link is missing,successfully log", pass); Assert.assertTrue("login link is missing, successfully log", pass);
} }
@Test @Test
public void checkForLogOut() { public void checkForLogOut() {
boolean pass = false;
email.logInLinkCLick(); email.logInLinkCLick();
email.fillFields("asda@dasd.asd", "12312eqs"); email.fillFields("asda@dasd.asd", "12312eqs");
email.logInButtonClick(); email.logInButtonClick();
context.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); context.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
String url = context.getDriver().getCurrentUrl(); try {
Assert.assertTrue(url.contains("https://ostin.com/#")); email.logInButtonDisplayed();
pass = true;
} catch (IllegalStateException e) {
e.printStackTrace();
}
Assert.assertTrue("test passed", pass);
} }
@After @After

View File

@ -35,33 +35,65 @@ public class NavigationTests {
@Test @Test
public void checkForSaleRedirect() { public void checkForSaleRedirect() {
boolean pass = false;
navigation.saleLinkClick(); navigation.saleLinkClick();
String url = context.getDriver().getCurrentUrl(); /*String url = context.getDriver().getCurrentUrl();
Assert.assertTrue(url.contains("https://ostin.com/ru/ru/catalog/sale/?m=SaleMarker")); Assert.assertTrue(url.contains("https://ostin.com/ru/ru/catalog/sale/?m=SaleMarker"));*/
try {
navigation.womaneSalesLink();
pass = true;
} catch (IllegalStateException e) {
e.printStackTrace();
}
Assert.assertTrue("test passed", pass);
} }
@Test @Test
public void checkForFemalesSaleRedirect() { public void checkForFemalesSaleRedirect() {
boolean pass = false;
navigation.saleFemaleLinkClick(); navigation.saleFemaleLinkClick();
String url = context.getDriver().getCurrentUrl(); /*String url = context.getDriver().getCurrentUrl();
Assert.assertTrue(url Assert.assertTrue(url
.contains("https://ostin.com/ru/ru/catalog/jenskaya_odejda/jenskaya_odejda_sale/?m=SaleMarker")); .contains("https://ostin.com/ru/ru/catalog/jenskaya_odejda/jenskaya_odejda_sale/?m=SaleMarker"));*/
try {
navigation.setMainTitle();
pass = true;
} catch (IllegalStateException e) {
e.printStackTrace();
}
Assert.assertTrue("passed", pass);
} }
@Test @Test
public void checkForBasementLinkRedirect() { public void checkForBasementLinkRedirect() {
boolean pass = false;
navigation.basementLinkClick(); navigation.basementLinkClick();
String url = context.getDriver().getCurrentUrl(); /*String url = context.getDriver().getCurrentUrl();
Assert.assertTrue(url.contains("https://ostin.com/ru/ru/pages/promo/")); Assert.assertTrue(url.contains("https://ostin.com/ru/ru/pages/promo/"));*/
try {
navigation.setDisplayedPromo();
pass = true;
} catch (IllegalStateException e) {
e.printStackTrace();
}
Assert.assertTrue("passed", pass);
} }
@Test @Test
public void checkForFollowSocialLink() { public void checkForFollowSocialLink() {
boolean pass = false;
navigation.socialElementLinkClcik(); navigation.socialElementLinkClcik();
Set<String> tabs = context.getDriver().getWindowHandles(); Set<String> tabs = context.getDriver().getWindowHandles();
context.getDriver().switchTo().window(Iterators.getLast(tabs.iterator())); context.getDriver().switchTo().window(Iterators.getLast(tabs.iterator()));
String url = context.getDriver().getCurrentUrl(); /*String url = context.getDriver().getCurrentUrl();
Assert.assertTrue(url.contains("https://vk.com/club20367999")); Assert.assertTrue(url.contains("https://vk.com/club20367999"));*/
try {
navigation.setPageName();
pass = true;
} catch (IllegalStateException e) {
e.printStackTrace();
}
Assert.assertTrue("passed", pass);
} }
@After @After

View File

@ -96,8 +96,16 @@ public class SortTests {
@Test @Test
public void checkForSearch() { public void checkForSearch() {
boolean pass = false;
sort.searching("куртка"); sort.searching("куртка");
context.getDriver().manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); context.getDriver().manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
try {
sort.setSearchingRequset();
pass = true;
} catch (IllegalStateException e) {
e.printStackTrace();
}
Assert.assertTrue("passed", pass);
} }
@After @After