113 lines
2.8 KiB
Java
113 lines
2.8 KiB
Java
package page;
|
|
|
|
import org.openqa.selenium.By;
|
|
import org.openqa.selenium.Keys;
|
|
import org.openqa.selenium.WebDriver;
|
|
import org.openqa.selenium.WebElement;
|
|
import org.openqa.selenium.interactions.Actions;
|
|
import org.openqa.selenium.support.FindBy;
|
|
|
|
public class LoginPage {
|
|
WebDriver driver;
|
|
|
|
@FindBy(css = ".header-fresh-user-partial-component__login-button")
|
|
private WebElement buttonLogin;
|
|
|
|
@FindBy(css = ".social-auth__item.social-auth__item_code_vk")
|
|
private WebElement buttonVK;
|
|
|
|
@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;
|
|
|
|
@FindBy(xpath = "//a[@href='/logout/']")
|
|
private WebElement buttonLogout;
|
|
|
|
public LoginPage(WebDriver driver) {
|
|
this.driver = driver;
|
|
}
|
|
|
|
public void clickButtonLogin() {
|
|
buttonLogin.click();
|
|
}
|
|
|
|
public void clickButtonVK() {
|
|
buttonVK.click();
|
|
}
|
|
|
|
public void clickButtonLogout() {
|
|
buttonLogout.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() {
|
|
while(true){
|
|
try{
|
|
if(driver.findElement(By.cssSelector(".social-auth__item.social-auth__item_code_vk")).isDisplayed()){
|
|
return;
|
|
} else {
|
|
Thread.sleep(500);
|
|
}
|
|
}catch(Exception ex){ }
|
|
}
|
|
}
|
|
|
|
public void isFrameLogin() {
|
|
while(true){
|
|
try{
|
|
if(driver.findElement(By.name("kp2-authapi-iframe")).isDisplayed()){
|
|
return;
|
|
} else {
|
|
Thread.sleep(500);
|
|
}
|
|
}catch(Exception ex){ }
|
|
}
|
|
}
|
|
|
|
public void isButtonLogin() {
|
|
while(true){
|
|
try{
|
|
if(driver.findElement(By.name("kp2-authapi-iframe")).isDisplayed()){
|
|
return;
|
|
} else {
|
|
Thread.sleep(500);
|
|
}
|
|
}catch(Exception ex){ }
|
|
}
|
|
}
|
|
|
|
public void frameDefault(){
|
|
driver.switchTo().defaultContent();
|
|
}
|
|
|
|
public void frameLogin(){
|
|
driver.switchTo().frame(signInFrame);
|
|
}
|
|
|
|
public boolean isAutorization() {
|
|
return elementAvatar.isDisplayed();
|
|
}
|
|
}
|