-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created page object classes for form authentication page - theinterne…
…t website
- Loading branch information
1 parent
e5ba9f5
commit a1fb776
Showing
4 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/test/java/io/github/mfaisalkhatri/pages/theinternet/FormAuthenticationPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/test/java/io/github/mfaisalkhatri/pages/theinternet/SecureAreaPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |