Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.tonicforhealth.test.core.page.web.logIn;
- import com.tonicforhealth.test.core.api.mailcatcher.MailCatcherApiClient;
- import com.tonicforhealth.test.core.extension.selenide.AopLoggingFactory;
- import com.tonicforhealth.test.core.page.web.HomePage;
- import com.tonicforhealth.test.core.page.web.adminaccount.AdminHomePage;
- import com.tonicforhealth.test.core.page.web.mytonic.AbstractWebPage;
- import org.springframework.stereotype.Component;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- import static com.codeborne.selenide.Selenide.$;
- import static com.tonicforhealth.test.core.extension.selenide.AopLoggingFactory.page;
- /**
- * @author Created by Vladimir Seleznov <v.e.seleznov@gmail.com> on 6/21/16.
- */
- @Component
- public class LoginPage extends AbstractWebPage<LoginPage> {
- private static final String USERNAME = "#username";
- private static final String PASSWORD = "#password";
- private static final String FORGOT_PASSWORD_LINK = "strong";
- private static final String ALREADY_A_MEMBER_LINK = ".widget-login-form__reset_password strong";
- private static final String RESET_PASSWORD_BUTTON = "#_submit";
- private static final String RESET_PASSWORD_NEW = "#fos_user_resetting_form_password";
- private static final String RESET_PASSWORD_CONFIRM = "#fos_user_resetting_form_confirmPassword";
- public HomePage builderLogIn(String username, String password) {
- $(USERNAME).setValue(username);
- $(PASSWORD).click();
- $(PASSWORD).setValue(password).pressEnter();
- return page(HomePage.class);
- }
- public AdminHomePage adminAccountLogIn(String username, String password) {
- $(USERNAME).setValue(username);
- $(PASSWORD).click();
- $(PASSWORD).setValue(password).pressEnter();
- return page(AdminHomePage.class);
- }
- public LoginPage open() {
- AopLoggingFactory.open("/builder/login");
- return this;
- }
- public LoginPage clickForgotPasswordLink() {
- $(FORGOT_PASSWORD_LINK).click();
- return this;
- }
- public LoginPage clickAlreadyAMemberLink() {
- $(ALREADY_A_MEMBER_LINK).click();
- return this;
- }
- public LoginPage clickResetPasswordButton() {
- $(RESET_PASSWORD_BUTTON).click();
- return this;
- }
- public LoginPage setEmail(String email) {
- $(USERNAME).setValue(email);
- return this;
- }
- public LoginPage setNewPassword(String password) {
- $(RESET_PASSWORD_NEW).setValue(password);
- return this;
- }
- public LoginPage setConfirmPassword(String password) {
- $(RESET_PASSWORD_CONFIRM).setValue(password);
- return this;
- }
- public LoginPage clickChangePasswordButton() {
- $(RESET_PASSWORD_BUTTON).click();
- return this;
- }
- public LoginPage openResetPasswordPageByLinkFromLastEmail() {
- MailCatcherApiClient api = new MailCatcherApiClient();
- String email = api.getEmailContent(api.getIdOfLastEmail());
- Pattern p = Pattern.compile("\\b(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]",
- Pattern.CASE_INSENSITIVE);
- Matcher m = p.matcher(email);
- String s = null;
- while (m.find()) {
- s = m.group(0);
- }
- AopLoggingFactory.open(s);
- return this;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement