Skalkin #6

Closed
antonskalkin73 wants to merge 9 commits from Skalkin into master
2 changed files with 67 additions and 25 deletions
Showing only changes of commit f65a77694a - Show all commits

View File

@ -5,6 +5,7 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.openqa.selenium.Dimension; import org.openqa.selenium.Dimension;
import org.openqa.selenium.Keys;
import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait; import org.openqa.selenium.support.ui.WebDriverWait;
@ -34,27 +35,37 @@ public class AutorizationTests {
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);//Выбрать пункт меню MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);//Выбрать пункт меню
page.clickButtonLogin(); 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); VKPage pageTo = PageFactory.initElements(context.getDriver(), VKPage.class);
Assertions.assertTrue(pageTo.isUserPresent()); Assertions.assertTrue(pageTo.isUserPresent());
} }
@Test @Test
public void testLoginEmail(){ public void testLoginEmail() throws InterruptedException {
context.getDriver().get(APP_URL);//Открыта страница фильма context.getDriver().get(APP_URL);//Открыта страница фильма
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);//Выбрать пункт меню MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);//Выбрать пункт меню
page.clickButtonLogin(); page.clickButtonLogin();
page.isButtonVK(); Thread.sleep(5000);
page.frameLogin();
page.clickButtonVK(); page.insertEmail("sefyijupsi@tutye.com");
page.insertPassword("q1w2e3r4t5y6");
Thread.sleep(1000);
page.insertSignInEnter();
page.frameDefault();
Assertions.assertTrue(page.isAutorization()); Assertions.assertTrue(page.isAutorization());
} }
} }

View File

@ -41,9 +41,21 @@ public class MainPage {
@FindBy(css = ".social-auth__item.social-auth__item_code_vk") @FindBy(css = ".social-auth__item.social-auth__item_code_vk")
private WebElement buttonVK; 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; 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) { public MainPage(WebDriver driver) {
this.driver = driver; this.driver = driver;
//this.driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); //this.driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
@ -54,9 +66,6 @@ public class MainPage {
builder.moveToElement(mainElement).perform(); builder.moveToElement(mainElement).perform();
menuElement.sendKeys(Keys.RETURN); menuElement.sendKeys(Keys.RETURN);
//menuElement.click();
} }
public void clickLogo() { public void clickLogo() {
@ -87,29 +96,51 @@ public class MainPage {
buttonVK.click(); 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() { 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"))); // .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(".social-auth__item.social-auth__item_code_vk")));
// dynamicElement.click(); // dynamicElement.click();
try { (new WebDriverWait(driver, 10))
Thread.sleep(10000); .until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("kp2-authapi-iframe"));
} catch (InterruptedException e) {
e.printStackTrace();
}
driver.findElement(By.cssSelector(".social-auth__item_code_vk")).click(); //driver.switchTo().frame(driver.findElement(By.cssSelector(".kp2-authapi-iframe")));
//dynamicElement.click();
}
@FindBy(css = ".kp2-authapi-iframe")
private WebElement signInFrame;
public void switchToCalcFrame(){
driver.switchTo().frame(signInFrame); driver.switchTo().frame(signInFrame);
driver.switchTo().frame(null);
//driver.findElement(By.cssSelector(".social-auth__item_code_vk")).click();
buttonVK.click();
driver.switchTo().defaultContent();
}
public void frameDefault(){
driver.switchTo().defaultContent();
}
public void frameLogin(){
driver.switchTo().frame(signInFrame);
}
public void switchToSocial(){
for (String winHandle : driver.getWindowHandles()) {
driver.switchTo().window(winHandle);
}
} }