Skip to content

Commit 0a18bfc

Browse files
author
Craig Mc Carthy
committed
JDK 17 - Playwright 1.49
0 parents  commit 0a18bfc

File tree

109 files changed

+5333
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+5333
-0
lines changed

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.java linguist-detectable=true
2+
*.js linguist-detectable=true
3+
*.html linguist-detectable=false
4+
*.css linguist-detectable=false
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Browser [e.g. chrome, safari]
29+
- Version [e.g. 22]
30+
31+
**Smartphone (please complete the following information):**
32+
- Device: [e.g. iPhone6]
33+
- OS: [e.g. iOS8.1]
34+
- Browser [e.g. stock browser, safari]
35+
- Version [e.g. 22]
36+
37+
**Additional context**
38+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/scripts/InstallChrome.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
sudo apt-get install xvfb
3+
4+
sudo apt-get install unzip
5+
6+
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
7+
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
8+
sudo apt-get update
9+
sudo apt install google-chrome-stable

.github/workflows/run.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Playwright Automated Testing Framework
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
push:
7+
branches: [ "**" ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Set up JDK 17
17+
uses: actions/setup-java@v4
18+
with:
19+
java-version: '17'
20+
distribution: 'temurin'
21+
cache: maven
22+
- name: Remove Chrome
23+
run: sudo apt purge google-chrome-stable
24+
- name: Remove default Chromium
25+
run: sudo apt purge chromium-browser
26+
27+
- name: Install Google Chrome # Using shell script to install Google Chrome
28+
run: |
29+
chmod +x ./.github/scripts/InstallChrome.sh
30+
./.github/scripts/InstallChrome.sh
31+
32+
- name: Test
33+
run: mvn clean test -Ptest

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Default ignored files
2+
/shelf/
3+
/.idea/workspace.xml
4+
/.idea

CONTRIBUTING.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Contributor Guidelines
2+
3+
Thank you for considering contributing to our project! We appreciate your interest in improving our repository and welcome any contributions you may have.
4+
5+
To ensure a smooth and collaborative experience for everyone, we have outlined some guidelines for contributing to this project. Please take a moment to review these guidelines before making your contribution.
6+
7+
## How to Contribute
8+
9+
1. **Fork the Repository**: Fork the repository to your own GitHub account.
10+
11+
2. **Clone the Repository**: Clone the forked repository to your local machine using the following command:
12+
```
13+
git clone https://github.com/your-username/repository.git
14+
```
15+
16+
3. **Create a Branch**: Create a new branch to work on your feature or bug fix using a descriptive name:
17+
```
18+
git checkout -b feature/your-feature
19+
```
20+
21+
4. **Make Changes**: Make your changes within the created branch. Ensure that your code follows the existing code style and conventions.
22+
23+
5. **Commit Changes**: Commit your changes with a descriptive commit message:
24+
```
25+
git commit -am 'Add a brief description of your changes'
26+
```
27+
28+
6. **Push Changes**: Push your changes to your forked repository:
29+
```
30+
git push origin feature/your-feature
31+
```
32+
33+
7. **Submit a Pull Request (PR)**: Once you have pushed your changes to your forked repository, navigate to the original repository and submit a pull request. Be sure to include a detailed description of the changes you have made.
34+
35+
8. **Code Review**: Your pull request will undergo review by the maintainers. Be prepared to address any feedback or suggestions.
36+
37+
9. **Merge**: Once your pull request has been approved and all feedback has been addressed, it will be merged into the main branch.
38+
39+
40+
## Reporting Bugs
41+
42+
If you encounter any bugs or issues while using our project, please report them by opening an issue in the GitHub repository. Include as much detail as possible, including steps to reproduce the issue.
43+
44+
## Feature Requests
45+
46+
We welcome suggestions for new features or improvements. If you have an idea for enhancing our project, please open an issue in the GitHub repository to discuss it.
47+
48+
## Additional Resources
49+
50+
- [GitHub Flow Guide](https://guides.github.com/introduction/flow/)
51+
- [How to Write a Git Commit Message](https://chris.beams.io/posts/git-commit/)
52+
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
53+
- [Markdown Syntax Guide](https://www.markdownguide.org/basic-syntax/)
54+
55+
Thank you for your contributions!
56+
57+
*(Please replace "your-username" and "repository" with your actual GitHub username and repository name in the commands above.)*

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 cmccarthyIrl
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
# Playwright Automated Testing Framework
2+
3+
[![Playwright Automated Testing Framework](https://github.com/cmccarthyIrl/playwright-java-test-harness/actions/workflows/run.yml/badge.svg)](https://github.com/cmccarthyIrl/playwright-java-test-harness/actions/workflows/run.yml)
4+
5+
# Index
6+
<table>
7+
<tr>
8+
<th>Start</th>
9+
<td>
10+
| <a href="#maven">Maven</a>
11+
| <a href="#quickstart">Quickstart</a> |
12+
</td>
13+
</tr>
14+
<tr>
15+
<th>Run</th>
16+
<td>
17+
| <a href="#command-line">Command Line</a>
18+
| <a href="#ide-support">IDE Support</a>
19+
| <a href="#java-jdk">Java JDK</a>
20+
| <a href="#troubleshooting">Troubleshooting</a> |
21+
| <a href="#environment-switching">Environment Switching</a>
22+
</td>
23+
</tr>
24+
<tr>
25+
<th>Report</th>
26+
<td>
27+
| <a href="#configuration">Configuration</a>
28+
| <a href="#logging">Logging</a> |
29+
</td>
30+
</tr>
31+
<tr>
32+
<th>Advanced</th>
33+
<td>
34+
| <a href="#contributing">Contributing</a> |
35+
</td>
36+
</tr>
37+
</table>
38+
39+
# Playwright Java Test Harness
40+
41+
This project is a test harness for using Playwright with Java for both UI and API testing. It is set up as a multi-module Maven project with two modules: `ui` for UI-based tests and `api` for API-based tests.
42+
43+
# Maven
44+
45+
The Framework uses [Playwright](https://spring.io/guides/gs/testing-web/) and [TestNG](https://testng.org/) client implementations.
46+
47+
```xml
48+
<dependency>
49+
<groupId>com.microsoft.playwright</groupId>
50+
<artifactId>playwright</artifactId>
51+
<version>1.49.0</version>
52+
</dependency>
53+
54+
<dependency>
55+
<groupId>org.testng</groupId>
56+
<artifactId>testng</artifactId>
57+
<version>7.10.2</version>
58+
</dependency>
59+
```
60+
61+
# Quickstart
62+
63+
- [Intellij IDE](https://www.jetbrains.com/idea/) - `Recommended`
64+
- [Java JDK 17](https://jdk.java.net/java-se-ri/11)
65+
- [Apache Maven](https://maven.apache.org/docs/3.6.3/release-notes.html)
66+
67+
# Command Line
68+
69+
Normally you will use your IDE to run a test via the `*Test.java` class. With the `Test` class,
70+
we can run tests from the command-line as well.
71+
72+
Note that the `mvn test` command only runs test classes that follow the `*Test.java` naming convention.
73+
74+
You can run a single test or a suite or tests like so :
75+
76+
```
77+
mvn test -Dtest=UITest
78+
```
79+
80+
Note that the `mvn clean install` command runs all test Classes that follow the `*Test.java` naming convention
81+
82+
```
83+
mvn clean install
84+
```
85+
86+
# IDE Support
87+
88+
To minimize the discrepancies between IDE versions and Locales the `<sourceEncoding>` is set to `UTF-8`
89+
90+
```xml
91+
92+
<properties>
93+
...
94+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
95+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
96+
...
97+
</properties>
98+
```
99+
100+
# Environment Switching
101+
102+
You can specify the profile to use when running Maven from the command line like so:
103+
104+
```
105+
mvn clean test -Ptest
106+
```
107+
108+
Example of a maven profile
109+
```xml
110+
111+
<profiles>
112+
...
113+
<profile>
114+
<id>test</id>
115+
<properties>
116+
<config.file>config-test.properties</config.file>
117+
</properties>
118+
</profile>
119+
...
120+
</profiles>
121+
```
122+
123+
124+
125+
# Java JDK
126+
127+
The Java version to use is defined in the `maven-compiler-plugin`
128+
129+
```xml
130+
131+
<build>
132+
...
133+
<pluginManagement>
134+
<plugins>
135+
...
136+
<plugin>
137+
<groupId>org.apache.maven.plugins</groupId>
138+
<artifactId>maven-compiler-plugin</artifactId>
139+
<configuration>
140+
<source>17</source>
141+
<target>17</target>
142+
</configuration>
143+
</plugin>
144+
...
145+
</plugins>
146+
</pluginManagement>
147+
...
148+
</build>
149+
```
150+
151+
# Logging
152+
153+
The Framework uses [SLF4J](https://www.slf4j.org/) You can instantiate the logging service in any Class
154+
like so
155+
156+
```java
157+
private static final LogManager log = new LogManager(UITest.class);
158+
```
159+
160+
you can then use the logger like so :
161+
162+
```java
163+
logger.info("This is a info message");
164+
logger.warn("This is a warning message");
165+
logger.debug("This is a info message");
166+
logger.error("This is a error message");
167+
```
168+
169+
170+
# Extent Reports
171+
172+
The Framework uses [Extent Reports Framework](https://extentreports.com/) to generate the HTML Test Reports
173+
174+
The example below is a report generated automatically by Extent Reports open-source library.
175+
176+
<img src="https://github.com/cmccarthyIrl/playwright-java-test-harness/blob/main/common/src/main/java/com/cmccarthyirl/common/demo/playwright-extent-report.png" height="400px"/>
177+
178+
179+
# License
180+
This project is open source and available under the [MIT License](https://github.com/cmccarthyIrl/playwright-java-test-harness/blob/main/LICENSE).
181+
182+
# Troubleshooting
183+
184+
- Execute the following commands to resolve any dependency issues
185+
1. `cd ~/install directory path/playwright-java-test-harness`
186+
2. `mvn clean install -DskipTests`
187+
188+
# Contributing
189+
190+
Spotted a mistake? Questions? Suggestions?
191+
192+
[Open an Issue](https://github.com/cmccarthyIrl/playwright-java-test-harness/issues)
193+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[2025-01-10 00:41:32,779] [main] [com.cmccarthyirl.common.XrayTestListener] ============= Starting test: testGetWeatherForDublin =============
2+
[2025-01-10 00:41:35,396] [main] [com.cmccarthyirl.api.test.WeatherAPITest] The weather for Dublin is: {"coord":{"lon":-121.9358,"lat":37.7021},"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01n"}],"base":"stations","main":{"temp":282.37,"feels_like":280.14,"temp_min":280.18,"temp_max":284.36,"pressure":1022,"humidity":59,"sea_level":1022,"grnd_level":996},"visibility":10000,"wind":{"speed":4.12,"deg":110},"clouds":{"all":0},"dt":1736429354,"sys":{"type":1,"id":4774,"country":"US","sunrise":1736436177,"sunset":1736471200},"timezone":-28800,"id":5344157,"name":"Dublin","cod":200}
3+
[2025-01-10 00:41:35,408] [main] [com.cmccarthyirl.common.XrayTestListener] ============= Passed test: testGetWeatherForDublin ==============

0 commit comments

Comments
 (0)