File tree Expand file tree Collapse file tree
src/test/java/io/github/mfaisalkhatri/pages/theinternet Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55public class ChallengingDomPage {
66
7- final Page page ;
7+ private final Page page ;
88
99 public ChallengingDomPage (final Page page ) {
1010 this .page = page ;
Original file line number Diff line number Diff line change 1+ package io .github .mfaisalkhatri .pages .theinternet ;
2+
3+ import com .microsoft .playwright .Locator ;
4+ import com .microsoft .playwright .Page ;
5+
6+ public class FormAuthenticationPage {
7+
8+ private final Page page ;
9+
10+ public FormAuthenticationPage (final Page page ) {
11+ this .page = page ;
12+ }
13+
14+ public String pageHeader () {
15+ return this .page .locator ("h2" ).innerHTML ();
16+ }
17+ private Locator userNameField () {
18+ return this .page .getByLabel ("Username" );
19+ }
20+
21+ private Locator passwordField () {
22+ return this .page .getByLabel ("Password" );
23+ }
24+
25+ private Locator loginBtn () {
26+ return this .page .getByText ("Login" );
27+ }
28+
29+ public SecureAreaPage performLogin (final String userName , final String password ) {
30+ userNameField ().clear ();
31+ userNameField ().fill (userName );
32+ passwordField ().clear ();
33+ passwordField ().fill (password );
34+ loginBtn ().click ();
35+ return new SecureAreaPage (this .page );
36+ }
37+ }
Original file line number Diff line number Diff line change 44
55public class MainPage {
66
7- final Page page ;
7+ private final Page page ;
88
99 public MainPage (final Page page ) {
1010 this .page = page ;
Original file line number Diff line number Diff line change 1+ package io .github .mfaisalkhatri .pages .theinternet ;
2+
3+ import com .microsoft .playwright .Locator ;
4+ import com .microsoft .playwright .Page ;
5+
6+ public class SecureAreaPage {
7+
8+ private final Page page ;
9+
10+ public SecureAreaPage (final Page page ) {
11+ this .page = page ;
12+ }
13+
14+ public String pageHeader () {
15+ return this .page .getByText ("Secure Area" ).textContent ();
16+ }
17+
18+ public String successMessage () {
19+ return this .page .locator ("#flash" ).textContent ();
20+ }
21+
22+ public String pageSubHeader () {
23+ return this .page .locator ("h4.subheader" ).innerText ();
24+ }
25+
26+ private Locator logoutBtn () {
27+ return this .page .locator ("a.button" );
28+ }
29+
30+ public void logoutFromWebsite () {
31+ logoutBtn ().click ();
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments