44import com .anhtester .helpers .PropertiesHelpers ;
55import com .anhtester .projects .cms .CommonPageCMS ;
66import com .anhtester .projects .cms .users .pages .dashboard .DashboardPage ;
7+
8+ import io .qameta .allure .Step ;
9+
710import org .openqa .selenium .By ;
811
912import static com .anhtester .keywords .WebUI .*;
@@ -16,7 +19,8 @@ public class LoginPageCMS extends CommonPageCMS {
1619 private By buttonCopyAdminAcc = By .xpath ("//button[normalize-space()='Copy']" );
1720 private By buttonSubmitLogin = By .xpath ("//button[normalize-space()='Login']" );
1821 private By titleLoginPage = By .xpath ("//h1[normalize-space() = 'Login to your account.']" );
19- private By messageRequiredEmail = By .xpath ("//strong[contains(text(),'The email field is required when phone is not present.')]" );
22+ private By messageRequiredEmail = By
23+ .xpath ("//strong[contains(text(),'The email field is required when phone is not present.')]" );
2024 private By inputEmail = By .xpath ("//input[@id='email']" );
2125 private By inputPassword = By .xpath ("//input[@id='password']" );
2226 private By messageAccDoesNotExist = By .xpath ("//span[@data-notify='message']" );
@@ -27,6 +31,7 @@ public void clickCloseAdvertisementPopup() {
2731 clickElement (closeAdvertisementPopup );
2832 }
2933
34+ @ Step ("Open login page" )
3035 public void openLoginPage () {
3136 openWebsite (FrameworkConstants .URL_CMS_USER );
3237 clickElement (closeAdvertisementPopup );
@@ -36,6 +41,7 @@ public void openLoginPage() {
3641 verifyElementVisible (titleLoginPage , "Login page is NOT displayed" );
3742 }
3843
44+ @ Step ("Verify redirect to Admin page" )
3945 public void verifyRedirectToAdminPage () {
4046 verifyElementVisible (avatarProfile , "Can not redirect to Admin page." );
4147 }
@@ -46,7 +52,8 @@ public void loginFailWithEmailNull() {
4652 clickElement (buttonSubmitLogin );
4753 waitForPageLoaded ();
4854 sleep (1 );
49- verifyEquals (getTextElement (messageRequiredEmail ).trim (), "The email field is required when phone is not present." , "" );
55+ verifyEquals (getTextElement (messageRequiredEmail ).trim (),
56+ "The email field is required when phone is not present." , "" );
5057 }
5158
5259 public void loginFailWithEmailDoesNotExist (String email , String password ) {
@@ -82,6 +89,7 @@ public void loginFailWithIncorrectPassword(String email, String password) {
8289 verifyElementVisible (messageAccDoesNotExist , "Password is failed but valid is NOT displayed." );
8390 }
8491
92+ @ Step ("Login with Customer account" )
8593 public void loginSuccessWithCustomerAccount (String email , String password ) {
8694 openLoginPage ();
8795 sleep (2 );
@@ -95,25 +103,23 @@ public void loginSuccessWithCustomerAccount(String email, String password) {
95103 verifyElementVisible (DashboardPage .titleDashboard , "Dashboard page is NOT displayed." );
96104 }
97105
106+ @ Step ("Login with Admin account" )
98107 public CommonPageCMS loginSuccessAdminPage (String email , String password ) {
99108 openWebsite (FrameworkConstants .URL_CMS_ADMIN );
100109 setText (inputEmail , email );
101110 setText (inputPassword , password );
102111 clickElement (buttonSubmitLogin );
103- waitForElementVisible (titleAnhTesterAdminPage );
104112 verifyElementVisible (titleAnhTesterAdminPage , "Admin page is NOT displayed." );
105113 return new CommonPageCMS ();
106114 }
107115
116+ @ Step ("Login with email and password from properties file" )
108117 public CommonPageCMS loginSuccessAdminPage () {
109118 openWebsite (FrameworkConstants .URL_CMS_ADMIN );
110119 setText (inputEmail , PropertiesHelpers .getValue ("email" ));
111120 setText (inputPassword , PropertiesHelpers .getValue ("password" ));
112121 clickElement (buttonSubmitLogin );
113- waitForElementVisible (titleAnhTesterAdminPage );
114122 verifyElementVisible (titleAnhTesterAdminPage , "Admin page is NOT displayed." );
115123 return new CommonPageCMS ();
116124 }
117125}
118-
119-
0 commit comments