mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
docs: Java Gradle installation (#26418)
Docs update to install Playwright as a dependency with Gradle, also introduce how to run Playwright CLI ```bash ./gradlew playwright --args="help" ``` Fixes [#571](https://github.com/microsoft/playwright-java/issues/571)
This commit is contained in:
parent
6e51b95e2c
commit
10eb7e8bc1
@ -186,3 +186,95 @@ junit.jupiter.execution.parallel.mode.classes.default = concurrent
|
|||||||
junit.jupiter.execution.parallel.config.strategy=dynamic
|
junit.jupiter.execution.parallel.config.strategy=dynamic
|
||||||
junit.jupiter.execution.parallel.config.dynamic.factor=0.5
|
junit.jupiter.execution.parallel.config.dynamic.factor=0.5
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Using Gradle
|
||||||
|
|
||||||
|
You can use a Gradle build configuration script, written in Groovy or Kotlin.
|
||||||
|
|
||||||
|
<Tabs
|
||||||
|
defaultValue="gradle"
|
||||||
|
values={[
|
||||||
|
{label: 'build.gradle', value: 'gradle'},
|
||||||
|
{label: 'build.gradle.kts', value: 'gradle-kotlin'}
|
||||||
|
]
|
||||||
|
}>
|
||||||
|
<TabItem value="gradle">
|
||||||
|
|
||||||
|
```java
|
||||||
|
plugins {
|
||||||
|
application
|
||||||
|
id 'java'
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation 'com.microsoft.playwright:playwright:%%VERSION%%'
|
||||||
|
}
|
||||||
|
|
||||||
|
application {
|
||||||
|
mainClass = 'org.example.App'
|
||||||
|
}
|
||||||
|
|
||||||
|
// Usage: ./gradlew playwright --args="help"
|
||||||
|
task playwright(type: JavaExec) {
|
||||||
|
classpath sourceSets.test.runtimeClasspath
|
||||||
|
mainClass = 'com.microsoft.playwright.CLI'
|
||||||
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value="gradle-kotlin">
|
||||||
|
|
||||||
|
```java
|
||||||
|
plugins {
|
||||||
|
application
|
||||||
|
id("java")
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation("com.microsoft.playwright:playwright:%%VERSION%%")
|
||||||
|
}
|
||||||
|
|
||||||
|
application {
|
||||||
|
mainClass.set("org.example.App")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Usage: ./gradlew playwright --args="help"
|
||||||
|
tasks.register<JavaExec>("playwright") {
|
||||||
|
classpath(sourceSets["test"].runtimeClasspath)
|
||||||
|
mainClass.set("com.microsoft.playwright.CLI")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.test {
|
||||||
|
useJUnitPlatform()
|
||||||
|
testLogging {
|
||||||
|
events("passed", "skipped", "failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
Tests can then be launched as follows:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./gradlew run
|
||||||
|
```
|
||||||
|
|
||||||
|
Also, Playwright command line tools can be run with :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./gradlew playwright --args="help"
|
||||||
|
```
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user