From 32cd4d5f6d27f633ca7531347f3f403f4e4827aa Mon Sep 17 00:00:00 2001 From: Anton Skalkin Date: Thu, 3 May 2018 11:44:42 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=B2=D1=81=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Skalkin/src/test/java/AutorizationTests.java | 23 ++++++-- Skalkin/src/test/java/page/MainPage.java | 58 ++++++++++++++++---- Skalkin/src/test/java/page/MoviePage.java | 19 ++++++- 3 files changed, 80 insertions(+), 20 deletions(-) diff --git a/Skalkin/src/test/java/AutorizationTests.java b/Skalkin/src/test/java/AutorizationTests.java index 1ba060d..8d9df5c 100644 --- a/Skalkin/src/test/java/AutorizationTests.java +++ b/Skalkin/src/test/java/AutorizationTests.java @@ -13,6 +13,7 @@ import page.*; public class AutorizationTests { private final static String APP_URL = "https://www.kinopoisk.ru/"; + private final static String APP_URL_MOVIE = "https://www.kinopoisk.ru/film/mstiteli-voyna-beskonechnosti-2018-843649/"; private static Context context; @@ -37,11 +38,10 @@ public class AutorizationTests { page.clickButtonLogin(); - Thread.sleep(5000); - //page.isButtonVK(); - //Thread.sleep(20000); + //Thread.sleep(5000); + page.isFrameLogin(); page.frameLogin(); - + page.isButtonVK(); page.clickButtonVK(); page.frameDefault(); @@ -58,14 +58,25 @@ public class AutorizationTests { MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);//Выбрать пункт меню page.clickButtonLogin(); - Thread.sleep(5000); + page.isFrameLogin(); page.frameLogin(); page.insertEmail("sefyijupsi@tutye.com"); page.insertPassword("q1w2e3r4t5y6"); - Thread.sleep(1000); + //page.isRestartPage(); + Thread.sleep(500); page.insertSignInEnter(); page.frameDefault(); Assertions.assertTrue(page.isAutorization()); } + + @Test + public void testLike() throws InterruptedException { + context.getDriver().get(APP_URL_MOVIE);//Открыта страница фильма + + MoviePage page = PageFactory.initElements(context.getDriver(), MoviePage.class);//Выбрать пункт меню + page.clickLike(); + + Assertions.assertTrue(page.isErrorLike()); + } } \ No newline at end of file diff --git a/Skalkin/src/test/java/page/MainPage.java b/Skalkin/src/test/java/page/MainPage.java index a8505a4..d0d6e75 100644 --- a/Skalkin/src/test/java/page/MainPage.java +++ b/Skalkin/src/test/java/page/MainPage.java @@ -9,6 +9,7 @@ import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; +import java.io.Console; import java.util.concurrent.TimeUnit; public class MainPage { @@ -114,25 +115,60 @@ public class MainPage { // .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(".social-auth__item.social-auth__item_code_vk"))); // dynamicElement.click(); - (new WebDriverWait(driver, 10)) - .until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("kp2-authapi-iframe")); +// (new WebDriverWait(driver, 10)) +// .until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.name("kp2-authapi-iframe"))); + int i = 1; + while(true){ + try{ + if(driver.findElement(By.cssSelector(".social-auth__item.social-auth__item_code_vk")).isDisplayed()){ + return; + } else { + Thread.sleep(500); + System.out.println(i++); + } + }catch(Exception ex){ } + } + //driver.switchTo().frame(driver.findElement(By.cssSelector(".kp2-authapi-iframe")));* - //driver.switchTo().frame(driver.findElement(By.cssSelector(".kp2-authapi-iframe"))); +// driver.switchTo().frame(signInFrame); +// +// //driver.findElement(By.cssSelector(".social-auth__item_code_vk")).click(); +// buttonVK.click(); +// driver.switchTo().defaultContent(); + } - driver.switchTo().frame(signInFrame); + public void isFrameLogin() { + int i = 1; + while(true){ + try{ + if(driver.findElement(By.name("kp2-authapi-iframe")).isDisplayed()){ + return; + } else { + Thread.sleep(500); + System.out.println(i++); + } + }catch(Exception ex){ } + } + } - //driver.findElement(By.cssSelector(".social-auth__item_code_vk")).click(); - buttonVK.click(); - driver.switchTo().defaultContent(); + public void isButtonLogin() { + int i = 1; + while(true){ + try{ + if(driver.findElement(By.name("kp2-authapi-iframe")).isDisplayed()){ + return; + } else { + Thread.sleep(500); + System.out.println(i++); + } + }catch(Exception ex){ } + } } public void frameDefault(){ driver.switchTo().defaultContent(); } - - - public void frameLogin(){ driver.switchTo().frame(signInFrame); } @@ -143,8 +179,6 @@ public class MainPage { } } - - public boolean isUserPresent() { return topBaners.isDisplayed(); } diff --git a/Skalkin/src/test/java/page/MoviePage.java b/Skalkin/src/test/java/page/MoviePage.java index d19881b..c6ece88 100644 --- a/Skalkin/src/test/java/page/MoviePage.java +++ b/Skalkin/src/test/java/page/MoviePage.java @@ -13,6 +13,16 @@ public class MoviePage { @FindBy(css = ".ya-share2__list a") private WebElement socialElement; + @FindBy(id = "btn_fav_film") + private WebElement buttonLike; + + @FindBy(id = "ui_notice_container") + private WebElement infoError; + + public MoviePage(WebDriver driver) { + this.driver = driver; + } + public void clickInfo() { infoElement.click(); @@ -23,6 +33,11 @@ public class MoviePage { } + public void clickLike() { + buttonLike.click(); + + } + public void switchToSocial(){ for (String winHandle : driver.getWindowHandles()) { @@ -31,8 +46,8 @@ public class MoviePage { } - public MoviePage(WebDriver driver) { - this.driver = driver; + public boolean isErrorLike() { + return infoError.isDisplayed(); } public boolean isUserPresent() {