Skip to content

This project uses Java and Playwright to provide a basic test harness. UI and API test examples provided

License

Notifications You must be signed in to change notification settings

cmccarthyIrl/playwright-java-testng-test-harness

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Playwright Automated Testing Framework

Playwright Automated Testing Framework

Index

Start | Maven | Quickstart |
Run | Command Line | IDE Support | Java JDK | Troubleshooting | | Environment Switching
Report | Configuration | Logging |
Advanced | Contributing |

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 and TestNG client implementations.

      <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

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

<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

<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

<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 You can instantiate the logging service in any Class like so

private static final LogManager log = new LogManager(UITest.class);

you can then use the logger like so :

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 to generate the HTML Test Reports

The example below is a report generated automatically by Extent Reports open-source library.

License

This project is open source and available under the MIT 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

About

This project uses Java and Playwright to provide a basic test harness. UI and API test examples provided

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy