Skalkin #6

Closed
antonskalkin73 wants to merge 9 commits from Skalkin into master
3 changed files with 80 additions and 20 deletions
Showing only changes of commit 32cd4d5f6d - Show all commits

View File

@ -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());
}
}

View File

@ -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();
}

View File

@ -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() {