Skip to content

Commit

Permalink
created page object classes for form authentication page - theinterne…
Browse files Browse the repository at this point in the history
…t website
  • Loading branch information
mfaisalkhatri committed Oct 5, 2023
1 parent e5ba9f5 commit a1fb776
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public class ChallengingDomPage {

final Page page;
private final Page page;

public ChallengingDomPage(final Page page) {
this.page = page;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package io.github.mfaisalkhatri.pages.theinternet;

import com.microsoft.playwright.Locator;
import com.microsoft.playwright.Page;

public class FormAuthenticationPage {

private final Page page;

public FormAuthenticationPage(final Page page) {
this.page = page;
}

public String pageHeader() {
return this.page.locator("h2").innerHTML();
}
private Locator userNameField() {
return this.page.getByLabel("Username");
}

private Locator passwordField() {
return this.page.getByLabel("Password");
}

private Locator loginBtn() {
return this.page.getByText("Login");
}

public SecureAreaPage performLogin(final String userName, final String password) {
userNameField().clear();
userNameField().fill(userName);
passwordField().clear();
passwordField().fill(password);
loginBtn().click();
return new SecureAreaPage(this.page);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public class MainPage {

final Page page;
private final Page page;

public MainPage(final Page page) {
this.page = page;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.github.mfaisalkhatri.pages.theinternet;

import com.microsoft.playwright.Locator;
import com.microsoft.playwright.Page;

public class SecureAreaPage {

private final Page page;

public SecureAreaPage(final Page page) {
this.page = page;
}

public String pageHeader() {
return this.page.getByText("Secure Area").textContent();
}

public String successMessage() {
return this.page.locator("#flash").textContent();
}

public String pageSubHeader () {
return this.page.locator("h4.subheader").innerText();
}

private Locator logoutBtn() {
return this.page.locator("a.button");
}

public void logoutFromWebsite() {
logoutBtn().click();
}
}

0 comments on commit a1fb776

Please sign in to comment.