GitHub - giulong/spectrum: Modern Selenium framework · GitHub
Skip to content

giulong/spectrum

Folders and files


Table of Contents
  1. About
  2. Getting Started
  3. Usage
  4. Contributing
  5. Acknowledgments

About

Spectrum is an e2e test automation framework that leverages JUnit 6 and Selenium 4 to provide these features automatically:

Spectrum manages all the boilerplate code, allowing you to focus on test logic: write a JUnit test using the vanilla Selenium API, and Spectrum will enrich your suite transparently.

Getting Started

⚠️ Spectrum requires Java 21 or newer.

The easiest way is to take the three steps listed below, as shown in this video:

Spectrum.project.creation.mp4
  1. Generate a new project leveraging the Spectrum Archetype:

    mvn archetype:generate -DarchetypeGroupId=io.github.giulong -DarchetypeArtifactId=spectrum-archetype
    
  2. Run the LoginFormIT demo test.

  3. Check the generated report, which opens automatically in your browser.

⚠️ Tests run on Chrome by default. As shown in the video above, you can change this with:
-Dspectrum.driver=firefox, -Dspectrum.driver=edge or -Dspectrum.driver=safari

Here's an overview of the project created by the archetype, along with the generated report and video:

login-form  report

video-readme.mp4

You can also configure Spectrum to produce additional reports, such as summary and coverage:

summary  html testbook

If you like Spectrum, please consider giving it a GitHub Star ⭐

Usage

Starting without the archetype is as simple as following these steps:

  1. Add the Spectrum dependency to your project, you can find the snippet for every build tool here.

    <dependency>
        <groupId>io.github.giulong</groupId>
        <artifactId>spectrum</artifactId>
        <version>1.30.1</version>
        <scope>test</scope>
    </dependency>
  2. Create the HelloWorldIT test class extending SpectrumTest:

    import io.github.giulong.spectrum.SpectrumTest;
    import org.junit.jupiter.api.Test;
    
    public class HelloWorldIT extends SpectrumTest<Void> {
    
        @Test
        public void dummyTest() {
            driver.get(configuration.getApplication().getBaseUrl());
        }
    }
  3. create a basic src/test/resources/configuration.yaml:

    application:
      baseUrl: https://the-internet.herokuapp.com/ # Change it with your app's landing page
    
    # video of the execution attached to the html report
    # (will be empty since the test is doing nothing)
    video:
      frames:
        - autoBefore
    
    # the html report will open automatically in your browser after the execution
    extent:
      openAtEnd: true
  4. Run the test!

Contributing

Contributions to Spectrum are welcome! Please check out the CONTRIBUTING.md and the open issues.

Acknowledgments

Spectrum leverages these projects you should definitely check out!