1
- package io .github .tahanima .page . login ;
1
+ package io .github .tahanima .ui . page ;
2
2
3
3
import static io .github .tahanima .config .ConfigurationManager .config ;
4
4
5
5
import com .microsoft .playwright .Locator ;
6
6
7
- import io .github .tahanima .page . BasePage ;
7
+ import io .github .tahanima .factory . BasePageFactory ;
8
8
import io .qameta .allure .Step ;
9
9
10
10
/**
11
11
* @author tahanima
12
12
*/
13
- public class LoginPage extends BasePage {
13
+ public final class LoginPage extends BasePage {
14
14
15
15
@ Step ("Navigate to the login page" )
16
- public LoginPage navigateToUrl () {
16
+ public LoginPage open () {
17
17
page .navigate (config ().baseUrl ());
18
18
19
19
return this ;
20
20
}
21
21
22
22
@ Step ("Type <username> into 'Username' textbox" )
23
- public LoginPage typeUsernameIntoTextBox ( String username ) {
23
+ public LoginPage typeUsername ( final String username ) {
24
24
page .fill ("id=user-name" , username );
25
25
26
26
return this ;
27
27
}
28
28
29
29
@ Step ("Type <password> into 'Password' textbox" )
30
- public LoginPage typePasswordIntoTextBox ( String password ) {
30
+ public LoginPage typePassword ( final String password ) {
31
31
page .fill ("id=password" , password );
32
32
33
33
return this ;
@@ -39,7 +39,18 @@ public Locator getErrorMessage() {
39
39
}
40
40
41
41
@ Step ("Click on the 'Login' button" )
42
- public void clickOnLoginButton () {
42
+ public ProductsPage submitLogin () {
43
43
page .click ("id=login-button" );
44
+
45
+ return BasePageFactory .createInstance (page , ProductsPage .class );
46
+ }
47
+
48
+ @ Step ("Login attempt to Swag Labs" )
49
+ public ProductsPage loginAs (final String username , final String password ) {
50
+ open ();
51
+ typeUsername (username );
52
+ typePassword (password );
53
+
54
+ return submitLogin ();
44
55
}
45
56
}
0 commit comments