From f65a77694aa736781992d4d68af42d3d4df2e945 Mon Sep 17 00:00:00 2001 From: Anton Skalkin Date: Sun, 29 Apr 2018 18:54:28 +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=B1=D0=BE=D0=BB=D1=8C=D1=88=D0=B0=D1=8F=20=D1=87=D0=B0=D1=81?= =?UTF-8?q?=D1=82=D1=8C=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B.=20=D0=97?= =?UTF-8?q?=D0=B0=D0=BA=D0=BE=D0=BD=D1=87=D0=B5=D0=BD=D1=8B=20=D0=BD=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D0=B3=D0=B0=D1=86=D0=B8=D1=8F=20=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B8=D1=81=D0=BA.=20=D0=9E=D1=81=D1=82=D0=B0=D0=BB?= =?UTF-8?q?=D0=BE=D1=81=D1=8C=201=20=D0=BA=D0=B5=D0=B9=D1=81=20=D0=B0?= =?UTF-8?q?=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Skalkin/src/test/java/AutorizationTests.java | 29 ++++++--- Skalkin/src/test/java/page/MainPage.java | 63 +++++++++++++++----- 2 files changed, 67 insertions(+), 25 deletions(-) diff --git a/Skalkin/src/test/java/AutorizationTests.java b/Skalkin/src/test/java/AutorizationTests.java index 5f02501..1ba060d 100644 --- a/Skalkin/src/test/java/AutorizationTests.java +++ b/Skalkin/src/test/java/AutorizationTests.java @@ -5,6 +5,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.openqa.selenium.Dimension; +import org.openqa.selenium.Keys; import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; @@ -34,27 +35,37 @@ public class AutorizationTests { MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);//Выбрать пункт меню page.clickButtonLogin(); - page.switchToCalcFrame(); - page.isButtonVK(); - //Thread.sleep(20000); - //page.clickButtonVK(); + + Thread.sleep(5000); + //page.isButtonVK(); + //Thread.sleep(20000); + page.frameLogin(); + + + page.clickButtonVK(); + page.frameDefault(); + page.switchToSocial(); + VKPage pageTo = PageFactory.initElements(context.getDriver(), VKPage.class); Assertions.assertTrue(pageTo.isUserPresent()); } @Test - public void testLoginEmail(){ + public void testLoginEmail() throws InterruptedException { context.getDriver().get(APP_URL);//Открыта страница фильма MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);//Выбрать пункт меню page.clickButtonLogin(); - page.isButtonVK(); - - page.clickButtonVK(); + Thread.sleep(5000); + page.frameLogin(); + page.insertEmail("sefyijupsi@tutye.com"); + page.insertPassword("q1w2e3r4t5y6"); + Thread.sleep(1000); + page.insertSignInEnter(); + page.frameDefault(); Assertions.assertTrue(page.isAutorization()); - } } \ 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 c143a05..a8505a4 100644 --- a/Skalkin/src/test/java/page/MainPage.java +++ b/Skalkin/src/test/java/page/MainPage.java @@ -41,9 +41,21 @@ public class MainPage { @FindBy(css = ".social-auth__item.social-auth__item_code_vk") private WebElement buttonVK; - @FindBy(css = ".header-fresh-user-partial-component__button.header-fresh-user-partial-component__button_selected") + @FindBy(css = ".header-fresh-user-partial-component__avatar") private WebElement elementAvatar; + @FindBy(name = "login") + private WebElement elementEmail; + + @FindBy(name = "password") + private WebElement elementPassword; + + @FindBy(css = ".link.link_secondary.auth__signup-link") + private WebElement elementRegister; + + @FindBy(css = ".kp2-authapi-iframe") + private WebElement signInFrame; + public MainPage(WebDriver driver) { this.driver = driver; //this.driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); @@ -54,9 +66,6 @@ public class MainPage { builder.moveToElement(mainElement).perform(); menuElement.sendKeys(Keys.RETURN); - - - //menuElement.click(); } public void clickLogo() { @@ -87,29 +96,51 @@ public class MainPage { buttonVK.click(); } + public void insertEmail(String str) { + elementEmail.sendKeys(str); + } + + public void insertPassword(String str) { + elementPassword.sendKeys(str); + } + + public void insertSignInEnter() { + elementPassword.sendKeys(Keys.ENTER); + } + public void isButtonVK() { -// WebElement dynamicElement = (new WebDriverWait(driver, 30)) +// WebElement dynamicElement = (new WebDriverWait(driver, 30)) +// .until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("kp2-authapi-iframe")); // .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(".social-auth__item.social-auth__item_code_vk"))); // dynamicElement.click(); - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - e.printStackTrace(); - } + (new WebDriverWait(driver, 10)) + .until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("kp2-authapi-iframe")); - driver.findElement(By.cssSelector(".social-auth__item_code_vk")).click(); - //dynamicElement.click(); + //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(); } - @FindBy(css = ".kp2-authapi-iframe") - private WebElement signInFrame; + public void frameDefault(){ + driver.switchTo().defaultContent(); + } - public void switchToCalcFrame(){ + + + public void frameLogin(){ driver.switchTo().frame(signInFrame); - driver.switchTo().frame(null); + } + public void switchToSocial(){ + for (String winHandle : driver.getWindowHandles()) { + driver.switchTo().window(winHandle); + } }