Code Monkey home page Code Monkey logo

gradle-playwright-plugin's Introduction

Gradle Playwright Plugin

A simple Plugin to use Playwright in a gradle JVM project

Usage

In the plugins block, import the net.hydrashead.gradle-playwright plugin:

plugins {
    // Apply the Kotlin JVM plugin to add support for Kotlin.
    id("net.hydrashead.gradle-playwright") version "0.0.2"
}

The plugin will automagically import the java plugin if it s not already loaded in order to create a new sourceset.

Add your tests to the playwright source set and use the :playwrightTest command to launch the tests.

Example

Using the Kotest library as an example:

package net.hydrashead.test.playwright

import com.microsoft.playwright.BrowserType
import com.microsoft.playwright.Playwright
import io.kotest.core.spec.style.BehaviorSpec
import io.kotest.matchers.string.shouldContain

class SampleTest : BehaviorSpec({
    Given("A playwright module") {
        val playwrightInst = Playwright.create()
        playwrightInst.use { playwright ->
            And("A Firefox Browser") {
                val browser =
                    playwright.firefox().launch(BrowserType.LaunchOptions().setHeadless(false).setSlowMo(50.0))
                val page = browser.newPage()
                When("We navigate to Playwright.dev") {
                    page.navigate("https://playwright.dev/java")
                    Then("The page title contains Playwright Java") {
                        page.title() shouldContain "Playwright Java"
                    }
                }
            }
            And("A Chromium Browser") {
                val browser =
                    playwright.chromium().launch(BrowserType.LaunchOptions().setHeadless(false).setSlowMo(50.0))
                val page = browser.newPage()
                When("We navigate to Playwright.dev") {
                    page.navigate("https://playwright.dev/java")
                    Then("The page title contains Playwright Java") {
                        page.title() shouldContain "Playwright Java"
                    }
                }
            }
        }
    }
})

Config

Use the playwright block in the build.gradle.

Available options are:

  • toolVersion: Sets the playwright version to use. Defaults to 1.27.0
playwright {
    toolVersion.set("1.27.0")
}

Contributing

Coming soon.

gradle-playwright-plugin's People

Contributors

hydragyrum avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.