1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
package com.mavlushechka.a1qa.pages;
import com.mavlushechka.a1qa.elements.Button;
import com.mavlushechka.a1qa.elements.Field;
import com.mavlushechka.a1qa.elements.Label;
import com.mavlushechka.a1qa.models.User;
import org.openqa.selenium.By;
public class LoginForm extends BaseForm {
private final Field passwordField = new Field(By.xpath("//*[contains(@class, 'login-form__field-row') and not(contains(@class, 'align'))]//input"), "Password");
private final Field emailField = new Field(By.xpath("//*[contains(@class, 'login-form__field-row')]//*[contains(@class, 'align__cell')]//input"), "Email");
private final Field emailServerField = new Field(By.xpath("//*[contains(@class, 'login-form__field-row')]//*[contains(@class, 'align__cell')]//input[contains(@placeholder, 'Domain')]"), "Domain");
private final Button dropdownOpenerButton = new Button(By.xpath("//*[contains(@class, 'dropdown__opener')]"), "Dropdown opener");
private final Button termsAndConditionsCheckbox = new Button(By.xpath("//*[contains(@class, 'checkbox')]"), "Terms and conditions checkbox");
private final Button nextButton = new Button(By.xpath("//*[contains(@class, 'button-container__secondary')]//a[contains(@class, 'button--secondary') and not(contains(@class, 'u-right'))]"), "Next");
private final String dropdownListItemXpath = "//*[contains(@class, 'dropdown__list')]//*[contains(text(), '%s')]";
public LoginForm() {
super(new Label(By.xpath("//*[contains(@class, 'login-form')]"), "Login"), "Login");
}
public void performAuthorization(User user) {
clearFields();
passwordField.sendKeys(user.password(), true);
emailField.sendKeys(user.email().username());
emailServerField.sendKeys(user.email().server());
dropdownOpenerButton.click();
new Button(By.xpath(dropdownListItemXpath.formatted(user.email().domain())), "Domain").click();
termsAndConditionsCheckbox.click();
nextButton.click();
}
private void clearFields() {
passwordField.clear();
emailField.clear();
emailServerField.clear();
}
}
|