-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Craig Mc Carthy
committed
Jan 9, 2025
0 parents
commit a2c0461
Showing
42 changed files
with
1,663 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.java linguist-detectable=true | ||
*.js linguist-detectable=true | ||
*.html linguist-detectable=false | ||
*.css linguist-detectable=false |
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,38 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**Desktop (please complete the following information):** | ||
- OS: [e.g. iOS] | ||
- Browser [e.g. chrome, safari] | ||
- Version [e.g. 22] | ||
|
||
**Smartphone (please complete the following information):** | ||
- Device: [e.g. iPhone6] | ||
- OS: [e.g. iOS8.1] | ||
- Browser [e.g. stock browser, safari] | ||
- Version [e.g. 22] | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
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,20 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
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,9 @@ | ||
#!/bin/bash | ||
sudo apt-get install xvfb | ||
|
||
sudo apt-get install unzip | ||
|
||
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - | ||
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' | ||
sudo apt-get update | ||
sudo apt install google-chrome-stable |
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 @@ | ||
name: Playwright Automated Testing Framework | ||
|
||
on: | ||
pull_request: | ||
branches: [ "main" ] | ||
push: | ||
branches: [ "**" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: maven | ||
- name: Remove Chrome | ||
run: sudo apt purge google-chrome-stable | ||
- name: Remove default Chromium | ||
run: sudo apt purge chromium-browser | ||
|
||
- name: Install Google Chrome # Using shell script to install Google Chrome | ||
run: | | ||
chmod +x ./.github/scripts/InstallChrome.sh | ||
./.github/scripts/InstallChrome.sh | ||
- name: Test | ||
run: mvn clean test -Ptest |
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,7 @@ | ||
# Default ignored files | ||
/shelf/ | ||
/.idea/workspace.xml | ||
/.idea | ||
/ui/target/ | ||
/common/target/ | ||
/api/target/ |
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,57 @@ | ||
# Contributor Guidelines | ||
|
||
Thank you for considering contributing to our project! We appreciate your interest in improving our repository and welcome any contributions you may have. | ||
|
||
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. | ||
|
||
## How to Contribute | ||
|
||
1. **Fork the Repository**: Fork the repository to your own GitHub account. | ||
|
||
2. **Clone the Repository**: Clone the forked repository to your local machine using the following command: | ||
``` | ||
git clone https://github.com/your-username/repository.git | ||
``` | ||
3. **Create a Branch**: Create a new branch to work on your feature or bug fix using a descriptive name: | ||
``` | ||
git checkout -b feature/your-feature | ||
``` | ||
4. **Make Changes**: Make your changes within the created branch. Ensure that your code follows the existing code style and conventions. | ||
5. **Commit Changes**: Commit your changes with a descriptive commit message: | ||
``` | ||
git commit -am 'Add a brief description of your changes' | ||
``` | ||
6. **Push Changes**: Push your changes to your forked repository: | ||
``` | ||
git push origin feature/your-feature | ||
``` | ||
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. | ||
8. **Code Review**: Your pull request will undergo review by the maintainers. Be prepared to address any feedback or suggestions. | ||
9. **Merge**: Once your pull request has been approved and all feedback has been addressed, it will be merged into the main branch. | ||
## Reporting Bugs | ||
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. | ||
## Feature Requests | ||
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. | ||
## Additional Resources | ||
- [GitHub Flow Guide](https://guides.github.com/introduction/flow/) | ||
- [How to Write a Git Commit Message](https://chris.beams.io/posts/git-commit/) | ||
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/) | ||
- [Markdown Syntax Guide](https://www.markdownguide.org/basic-syntax/) | ||
Thank you for your contributions! | ||
*(Please replace "your-username" and "repository" with your actual GitHub username and repository name in the commands above.)* |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 cmccarthyIrl | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,193 @@ | ||
# Playwright Automated Testing Framework | ||
|
||
[](https://github.com/cmccarthyIrl/playwright-java-test-harness/actions/workflows/run.yml) | ||
|
||
# Index | ||
<table> | ||
<tr> | ||
<th>Start</th> | ||
<td> | ||
| <a href="#maven">Maven</a> | ||
| <a href="#quickstart">Quickstart</a> | | ||
</td> | ||
</tr> | ||
<tr> | ||
<th>Run</th> | ||
<td> | ||
| <a href="#command-line">Command Line</a> | ||
| <a href="#ide-support">IDE Support</a> | ||
| <a href="#java-jdk">Java JDK</a> | ||
| <a href="#troubleshooting">Troubleshooting</a> | | ||
| <a href="#environment-switching">Environment Switching</a> | ||
</td> | ||
</tr> | ||
<tr> | ||
<th>Report</th> | ||
<td> | ||
| <a href="#configuration">Configuration</a> | ||
| <a href="#logging">Logging</a> | | ||
</td> | ||
</tr> | ||
<tr> | ||
<th>Advanced</th> | ||
<td> | ||
| <a href="#contributing">Contributing</a> | | ||
</td> | ||
</tr> | ||
</table> | ||
|
||
# Playwright Java Test Harness | ||
|
||
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. | ||
|
||
# Maven | ||
|
||
The Framework uses [Playwright](https://spring.io/guides/gs/testing-web/) and [TestNG](https://testng.org/) client implementations. | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.microsoft.playwright</groupId> | ||
<artifactId>playwright</artifactId> | ||
<version>1.49.0</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<version>7.10.2</version> | ||
</dependency> | ||
``` | ||
|
||
# Quickstart | ||
|
||
- [Intellij IDE](https://www.jetbrains.com/idea/) - `Recommended` | ||
- [Java JDK 17](https://jdk.java.net/java-se-ri/11) | ||
- [Apache Maven](https://maven.apache.org/docs/3.6.3/release-notes.html) | ||
|
||
# Command Line | ||
|
||
Normally you will use your IDE to run a test via the `*Test.java` class. With the `Test` class, | ||
we can run tests from the command-line as well. | ||
|
||
Note that the `mvn test` command only runs test classes that follow the `*Test.java` naming convention. | ||
|
||
You can run a single test or a suite or tests like so : | ||
|
||
``` | ||
mvn test -Dtest=UITest | ||
``` | ||
|
||
Note that the `mvn clean install` command runs all test Classes that follow the `*Test.java` naming convention | ||
|
||
``` | ||
mvn clean install | ||
``` | ||
|
||
# IDE Support | ||
|
||
To minimize the discrepancies between IDE versions and Locales the `<sourceEncoding>` is set to `UTF-8` | ||
|
||
```xml | ||
|
||
<properties> | ||
... | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
... | ||
</properties> | ||
``` | ||
|
||
# Environment Switching | ||
|
||
You can specify the profile to use when running Maven from the command line like so: | ||
|
||
``` | ||
mvn clean test -Ptest | ||
``` | ||
|
||
Example of a maven profile | ||
```xml | ||
|
||
<profiles> | ||
... | ||
<profile> | ||
<id>test</id> | ||
<properties> | ||
<config.file>config-test.properties</config.file> | ||
</properties> | ||
</profile> | ||
... | ||
</profiles> | ||
``` | ||
|
||
|
||
|
||
# Java JDK | ||
|
||
The Java version to use is defined in the `maven-compiler-plugin` | ||
|
||
```xml | ||
|
||
<build> | ||
... | ||
<pluginManagement> | ||
<plugins> | ||
... | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>17</source> | ||
<target>17</target> | ||
</configuration> | ||
</plugin> | ||
... | ||
</plugins> | ||
</pluginManagement> | ||
... | ||
</build> | ||
``` | ||
|
||
# Logging | ||
|
||
The Framework uses [SLF4J](https://www.slf4j.org/) You can instantiate the logging service in any Class | ||
like so | ||
|
||
```java | ||
private static final LogManager log = new LogManager(UITest.class); | ||
``` | ||
|
||
you can then use the logger like so : | ||
|
||
```java | ||
logger.info("This is a info message"); | ||
logger.warn("This is a warning message"); | ||
logger.debug("This is a info message"); | ||
logger.error("This is a error message"); | ||
``` | ||
|
||
|
||
# Extent Reports | ||
|
||
The Framework uses [Extent Reports Framework](https://extentreports.com/) to generate the HTML Test Reports | ||
|
||
The example below is a report generated automatically by Extent Reports open-source library. | ||
|
||
<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"/> | ||
|
||
|
||
# License | ||
This project is open source and available under the [MIT License](https://github.com/cmccarthyIrl/playwright-java-test-harness/blob/main/LICENSE). | ||
|
||
# Troubleshooting | ||
|
||
- Execute the following commands to resolve any dependency issues | ||
1. `cd ~/install directory path/playwright-java-test-harness` | ||
2. `mvn clean install -DskipTests` | ||
|
||
# Contributing | ||
|
||
Spotted a mistake? Questions? Suggestions? | ||
|
||
[Open an Issue](https://github.com/cmccarthyIrl/playwright-java-test-harness/issues) | ||
|
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,3 @@ | ||
[2025-01-10 00:50:30,511] [main] [com.cmccarthyirl.common.XrayTestListener] ============= Starting test: testGetWeatherForDublin ============= | ||
[2025-01-10 00:50:32,903] [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":280.89,"feels_like":278.32,"temp_min":278.9,"temp_max":283.2,"pressure":1022,"humidity":66,"sea_level":1022,"grnd_level":996},"visibility":10000,"wind":{"speed":4.12,"deg":110},"clouds":{"all":0},"dt":1736430447,"sys":{"type":1,"id":4774,"country":"US","sunrise":1736436177,"sunset":1736471200},"timezone":-28800,"id":5344157,"name":"Dublin","cod":200} | ||
[2025-01-10 00:50:32,915] [main] [com.cmccarthyirl.common.XrayTestListener] ============= Passed test: testGetWeatherForDublin ============== |
Oops, something went wrong.