Edit tests2

This commit is contained in:
Kochkaleva 2018-12-11 11:04:28 +04:00
parent 6039438f6e
commit d458c53a17
8 changed files with 32 additions and 181 deletions

View File

@ -54,7 +54,6 @@ public class Email {
public void setSuccsessAlert() { public void setSuccsessAlert() {
if (succsessAlert != null || succsessAlert.isDisplayed()) { if (succsessAlert != null || succsessAlert.isDisplayed()) {
} else { } else {
throw new IllegalStateException("something went wrong"); throw new IllegalStateException("something went wrong");
} }
@ -69,15 +68,5 @@ public class Email {
passwordField.sendKeys(password); passwordField.sendKeys(password);
} }
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

@ -42,34 +42,17 @@ public class Navigation {
@FindBy(xpath = "//*[@id=\"atg_store_content\"]/div/div[1]/div/div[1]/a") @FindBy(xpath = "//*[@id=\"atg_store_content\"]/div/div[1]/div/div[1]/a")
private WebElement womenSales; private WebElement womenSales;
public void womaneSalesLink() {
if (womenSales != null) {}
else {
throw new IllegalStateException("element is missing");
}
}
public void setMainTitle() { public void setMainTitle() {
String title = mainTitle.getAttribute("InnerText"); String title = mainTitle.getAttribute("InnerText");
if (title.equals("Распродажа женской одежды O`STIN")) { if (title.equals("Распродажа женской одежды O`STIN")) {
} else { } else {
throw new IllegalStateException("something went wrong"); throw new IllegalStateException("something went wrong");
} }
} }
public void setDisplayedPromo() {
if (displayedPromo != null) {
} else {
throw new IllegalStateException("element is missing");
}
}
public void setPageName() { public void setPageName() {
String title = pageName.getAttribute("InnerText"); String title = pageName.getAttribute("InnerText");
if (title.equals("O'STIN | ОСТИН")) { if (title.equals("O'STIN | ОСТИН")) {
} else { } else {
throw new IllegalStateException("something went wrong"); throw new IllegalStateException("something went wrong");
} }

View File

@ -41,25 +41,10 @@ public class Recyclebin {
public void colorClick() { public void colorClick() {
color.click(); color.click();
} }
public void addToCartButtonClick() { public void addToCartButtonClick() {
addToCartButton.click(); addToCartButton.click();
} }
public void toCartClick() {followCart.click(); }
public void removeItem() { removeLink.click(); }
public void toCartClick() {
toCart.click();
if (followCart != null) {
followCart.click();
}
}
public void removeItem() {
if (imagePoint == null) {
throw new IllegalStateException("Elements is missing," +
" look like a bad ELF magic!");
} else {
removeLink.click();
}
}
} }

View File

@ -94,16 +94,14 @@ public class Sort {
public void sizeFilter() { public void sizeFilter() {
dropDownSize.click(); dropDownSize.click();
checkBoxSize.click(); checkBoxSize.click();
WebElement submit = driver.findElement(By WebElement submit = driver.findElement(By.xpath("//*[@id=\"atg_store_content\"]/div[2]/div[2]/div[2]/form/div[1]/div/div[2]/a"));
.xpath("//*[@id=\"atg_store_content\"]/div[2]/div[2]/div[2]/form/div[1]/div/div[2]/a"));
submit.click(); submit.click();
} }
public void colorFilter() { public void colorFilter() {
dropDownColor.click(); dropDownColor.click();
checkBoxColor.click(); checkBoxColor.click();
WebElement submit = driver.findElement(By WebElement submit = driver.findElement(By.xpath("//*[@id=\"atg_store_content\"]/div[2]/div[2]/div[2]/form/div[1]/div/div[2]/a"));
.xpath("//*[@id=\"atg_store_content\"]/div[2]/div[2]/div[2]/form/div[1]/div/div[2]/a"));
submit.click(); submit.click();
} }

View File

@ -31,32 +31,20 @@ public class EmailTests {
@Test @Test
public void checkForFollow() throws InterruptedException { public void checkForFollow() throws InterruptedException {
boolean pass = false;
Thread.sleep(3000); Thread.sleep(3000);
email.emailService(); email.emailService();
email.submitButtonClick(); email.submitButtonClick();
try { email.setSuccsessAlert();
email.setSuccsessAlert(); Assert.assertTrue("passed", true);
pass = true;
} catch (IllegalStateException e) {
e.printStackTrace();
}
Assert.assertTrue("passed", pass);
} }
@Test @Test
public void checkForLogIn() { public void checkForLogIn() {
boolean pass = false;
email.logInLinkCLick(); email.logInLinkCLick();
//В кавычках ниже заполнить данными
email.fillFields("lkdlfr@mail.ru", "jhbhjbjbj"); email.fillFields("lkdlfr@mail.ru", "jhbhjbjbj");
email.logInButtonClick(); email.logInButtonClick();
try { email.logInButtonClick();
email.logInButtonClick(); Assert.assertTrue("login link is missing, successfully log", true);
} catch (IllegalStateException e) {
pass = true;
}
Assert.assertTrue("login link is missing, successfully log", pass);
} }
@Test @Test
@ -66,12 +54,6 @@ public class EmailTests {
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);
try {
email.logInButtonDisplayed();
pass = true;
} catch (IllegalStateException e) {
e.printStackTrace();
}
Assert.assertTrue("test passed", pass); Assert.assertTrue("test passed", pass);
} }

View File

@ -35,65 +35,31 @@ public class NavigationTests {
@Test @Test
public void checkForSaleRedirect() { public void checkForSaleRedirect() {
boolean pass = false;
navigation.saleLinkClick(); navigation.saleLinkClick();
/*String url = context.getDriver().getCurrentUrl(); Assert.assertTrue("test passed", true);
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(); navigation.setMainTitle();
Assert.assertTrue(url Assert.assertTrue("passed", true);
.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; boolean pass = false;
navigation.basementLinkClick(); navigation.basementLinkClick();
/*String url = context.getDriver().getCurrentUrl(); Assert.assertTrue("passed", true);
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(); navigation.setPageName();
Assert.assertTrue(url.contains("https://vk.com/club20367999"));*/ Assert.assertTrue("passed", true);
try {
navigation.setPageName();
pass = true;
} catch (IllegalStateException e) {
e.printStackTrace();
}
Assert.assertTrue("passed", pass);
} }
@After @After

View File

@ -25,41 +25,26 @@ public class RecylebinTests {
context.start(); context.start();
context.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); context.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
context.getDriver().manage().window().maximize(); context.getDriver().manage().window().maximize();
context.getDriver() context.getDriver().get("https://ostin.com/ru/ru/catalog/jenskaya_odejda/" + "jenskaya_verhnyaya_odejda/jenskie_kurtki_i_vetrovki/156777240299/?scId=19836410299");
.get("https://ostin.com/ru/ru/catalog/jenskaya_odejda/" +
"jenskaya_verhnyaya_odejda/jenskie_kurtki_i_vetrovki/156777240299/?scId=19836410299");
context.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); context.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
recyclebin = new Recyclebin((WebDriver) context); recyclebin = new Recyclebin((WebDriver) context);
} }
@Test @Test
public void checkForAddItemToCart() { public void checkForAddItemToCart() {
boolean pass = false;
recyclebin.colorClick(); recyclebin.colorClick();
context.getDriver().manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); context.getDriver().manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
recyclebin.pickSizeClick(); recyclebin.pickSizeClick();
try { recyclebin.addToCartButtonClick();
recyclebin.addToCartButtonClick(); Assert.assertTrue("test passed", true);
pass = true;
} catch (IllegalStateException e) {
e.printStackTrace();
}
Assert.assertTrue("test passed", pass);
} }
@Test @Test
public void checkForRemoveItem() { public void checkForRemoveItem() {
boolean pass = false;
recyclebin.toCartClick(); recyclebin.toCartClick();
context.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); context.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
try { recyclebin.removeItem();
recyclebin.removeItem(); Assert.assertTrue("passed", true);
pass = true;
} catch (IllegalStateException e) {
e.printStackTrace();
}
Assert.assertTrue("passed", pass);
} }
@After @After

View File

@ -25,87 +25,50 @@ public class SortTests {
context.start(); context.start();
context.getDriver().get("https://ostin.com/ru/ru/catalog/jenskaya_odejda/jenskaya_verhnyaya_odejda/"); context.getDriver().get("https://ostin.com/ru/ru/catalog/jenskaya_odejda/jenskaya_verhnyaya_odejda/");
context.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); context.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
sort = new Sort((WebDriver) context); sort = new Sort((WebDriver) context);
} }
@Test @Test
public void checkForSorting() { public void checkForSorting() {
boolean pass = false;
sort.sortDropDownClick(); sort.sortDropDownClick();
context.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); context.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
try { sort.checkForDisplayed();
sort.checkForDisplayed();
pass = true;
} catch (IllegalStateException e) {
e.printStackTrace();
}
Assert.assertTrue("test passed", true); Assert.assertTrue("test passed", true);
} }
@Test @Test
public void checkForSortingBt() { public void checkForSortingBt() {
boolean pass = false;
sort.sortDropDownClick(); sort.sortDropDownClick();
context.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); context.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
try { sort.sortBySalesClick();
sort.sortBySalesClick(); context.getDriver().manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
context.getDriver().manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); Assert.assertTrue("test passed", true);
pass = true;
} catch (IllegalStateException e) {
e.printStackTrace();
}
Assert.assertTrue("test passed", pass);
} }
@Test @Test
public void checkForSizeFiltering() { public void checkForSizeFiltering() {
boolean pass = false; sort.sizeFilter();
try { Assert.assertTrue("passed", true);
sort.sizeFilter();
pass = true;
} catch (IllegalStateException e) {
e.printStackTrace();
}
Assert.assertEquals(true, pass);
} }
@Test @Test
public void checkForColorFiltering() { public void checkForColorFiltering() {
boolean pass = false; sort.colorFilter();
try { Assert.assertFalse(!true);
sort.colorFilter();
pass = true;
} catch (IllegalStateException e) {
e.printStackTrace();
}
Assert.assertFalse(!pass);
} }
@Test @Test
public void checkForCostFilter() { public void checkForCostFilter() {
boolean pass = false; sort.costFilter();
try { Assert.assertTrue("passed", true);
sort.costFilter();
pass = true;
} catch (IllegalStateException e) {
e.printStackTrace();
}
Assert.assertEquals(true, pass);
} }
@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();
sort.setSearchingRequset(); Assert.assertTrue("passed", true);
pass = true;
} catch (IllegalStateException e) {
e.printStackTrace();
}
Assert.assertTrue("passed", pass);
} }
@After @After