Skip to content

Commit f2cf047

Browse files
committed
update
1 parent 78d16f7 commit f2cf047

File tree

22 files changed

+289
-228
lines changed

22 files changed

+289
-228
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ out
1616
*.iml
1717
atlassian-ide-plugin.xml
1818

19-
report
19+
testoutput

build.gradle

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,24 @@ dependencies {
2020
implementation 'com.univocity:univocity-parsers:2.9.1'
2121
implementation 'com.aventstack:extentreports:5.0.9'
2222
implementation 'com.microsoft.playwright:playwright:1.31.0'
23+
implementation 'org.apache.commons:commons-lang3:3.12.0'
24+
implementation 'org.apache.commons:commons-text:1.10.0'
2325
implementation 'org.slf4j:slf4j-api:2.0.6'
2426

25-
testCompileOnly 'org.projectlombok:lombok:1.18.26'
26-
testAnnotationProcessor 'org.projectlombok:lombok:1.18.26'
27+
compileOnly 'org.projectlombok:lombok:1.18.26'
28+
annotationProcessor 'org.projectlombok:lombok:1.18.26'
2729

2830
testImplementation 'org.testng:testng:7.7.1'
2931
testImplementation 'org.slf4j:slf4j-simple:2.0.6'
3032
}
3133

3234
test {
3335
systemProperties = System.getProperties() as Map<String, ?>
34-
def groups = System.getProperty('groups', 'regression')
35-
def thread = System.getProperty('thread', '5')
36+
def group = System.getProperty('group', 'regression')
37+
def thread = System.getProperty('thread', '100')
3638

3739
useTestNG() {
38-
includeGroups groups
40+
includeGroups group
3941
parallel 'classes'
4042
threadCount thread as int
4143
}

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
rootProject.name = 'playwright-test-automation-boilerplate'
1+
rootProject.name = 'playwright-java-test-automation-architecture'
22

src/test/java/io/github/tahanima/config/ConfigurationManager.java renamed to src/main/java/io/github/tahanima/config/ConfigurationManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ private ConfigurationManager() {}
1414
* @return an instance of Configuration class from an internal cache
1515
* @see <a href="http://owner.aeonbits.org/docs/singleton">reference</a>
1616
*/
17-
public static Configuration configuration() {
17+
public static Configuration config() {
1818
return ConfigCache.getOrCreate(Configuration.class);
1919
}
2020
}

src/test/java/io/github/tahanima/data/BaseData.java renamed to src/main/java/io/github/tahanima/data/BaseTestData.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.github.tahanima.data;
22

33
import com.univocity.parsers.annotations.Parsed;
4+
45
import lombok.Getter;
56
import lombok.ToString;
67

@@ -11,7 +12,7 @@
1112
*/
1213
@Getter
1314
@ToString
14-
public class BaseData {
15+
public class BaseTestData {
1516
@Parsed(field = "Test Case ID", defaultNullRead = "")
1617
private String testCaseId;
1718

src/test/java/io/github/tahanima/data/login/LoginData.java renamed to src/main/java/io/github/tahanima/data/login/LoginTestData.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package io.github.tahanima.data.login;
22

33
import com.univocity.parsers.annotations.Parsed;
4-
import io.github.tahanima.data.BaseData;
4+
5+
import io.github.tahanima.data.BaseTestData;
6+
57
import lombok.Getter;
68
import lombok.ToString;
79

@@ -12,7 +14,7 @@
1214
*/
1315
@Getter
1416
@ToString(callSuper = true)
15-
public class LoginData extends BaseData {
17+
public class LoginTestData extends BaseTestData {
1618
@Parsed(field = "User Name", defaultNullRead = "")
1719
private String userName;
1820

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package io.github.tahanima.page;
2+
3+
import static io.github.tahanima.config.ConfigurationManager.config;
4+
5+
import com.microsoft.playwright.Page;
6+
7+
import java.nio.file.Path;
8+
9+
/**
10+
* @author tahanima
11+
*/
12+
public class BasePage {
13+
protected Page page;
14+
15+
public void setAndConfigurePage(Page page) {
16+
this.page = page;
17+
page.setDefaultTimeout(config().timeout());
18+
}
19+
20+
private String getScreenshotFilePath(String path) {
21+
return config().baseScreenshotPath() + path;
22+
}
23+
24+
public void captureScreenshot(String fileName) {
25+
page.screenshot(
26+
new Page.ScreenshotOptions()
27+
.setPath(Path.of(String.format("%s.png", getScreenshotFilePath(fileName))))
28+
.setFullPage(true));
29+
}
30+
}

src/test/java/io/github/tahanima/pages/BasePageFactory.java renamed to src/main/java/io/github/tahanima/page/BasePageFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.github.tahanima.pages;
1+
package io.github.tahanima.page;
22

33
import com.microsoft.playwright.Page;
44

Original file line numberDiff line numberDiff line change
@@ -1,39 +1,40 @@
1-
package io.github.tahanima.pages.login;
1+
package io.github.tahanima.page.login;
2+
3+
import static io.github.tahanima.config.ConfigurationManager.config;
24

35
import com.microsoft.playwright.Locator;
4-
import io.github.tahanima.pages.BasePage;
56

6-
import static io.github.tahanima.config.ConfigurationManager.configuration;
7+
import io.github.tahanima.page.BasePage;
78

89
/**
910
* This class captures the relevant UI components and functionalities of the login page.
1011
*
1112
* @author tahanima
1213
*/
1314
public class LoginPage extends BasePage {
14-
public LoginPage goTo() {
15-
page.navigate(configuration().baseUrl());
15+
public LoginPage navigateToUrl() {
16+
page.navigate(config().baseUrl());
1617

1718
return this;
1819
}
1920

20-
public LoginPage enterUsername(String username) {
21+
public LoginPage fillUsernameInTextBox(String username) {
2122
page.fill("id=user-name", username);
2223

2324
return this;
2425
}
2526

26-
public LoginPage enterPassword(String password) {
27+
public LoginPage fillPasswordInTextBox(String password) {
2728
page.fill("id=password", password);
2829

2930
return this;
3031
}
3132

32-
public Locator getErrorMessageLocator() {
33+
public Locator getErrorMessage() {
3334
return page.locator(".error-message-container h3");
3435
}
3536

36-
public void clickLogin() {
37+
public void clickOnLoginButton() {
3738
page.click("id=login-button");
3839
}
3940
}

0 commit comments

Comments
 (0)