-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See #149
- Loading branch information
Showing
8 changed files
with
87 additions
and
2 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,3 @@ | ||
= Browser Automation with Playwrite | ||
|
||
The Playwrite Module provides the link:{javadoc-url}/selenium/org/shakespeareframework/playwrite/BrowseTheWeb.html[BrowseTheWeb Ability], which basically provides a managed https://playwright.dev/java/docs/intro[Playwrite Docs]. |
File renamed without changes.
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
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,32 @@ | ||
plugins { | ||
id 'shakespeare.module' | ||
} | ||
|
||
dependencies { | ||
api project(':modules:core') | ||
|
||
implementation 'com.microsoft.playwright:playwright:1.17.1' | ||
|
||
testImplementation 'org.slf4j:slf4j-api:1.7.36' | ||
testImplementation 'ch.qos.logback:logback-classic:1.2.11' | ||
|
||
testImplementation project(':modules:testutils') | ||
|
||
testImplementation platform('org.junit:junit-bom:5.8.2') | ||
testImplementation 'org.junit.jupiter:junit-jupiter-api' | ||
testImplementation 'org.junit.jupiter:junit-jupiter-params' | ||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' | ||
|
||
testImplementation 'org.assertj:assertj-core:3.22.0' | ||
} | ||
|
||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
pom { | ||
name = 'Shakespeare Playwrite' | ||
description = 'Module for browser automation via Playwrite.' | ||
} | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
modules/playwrite/src/main/java/org/shakespeareframework/playwrite/BrowseTheWeb.java
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,24 @@ | ||
package org.shakespeareframework.playwrite; | ||
|
||
import com.microsoft.playwright.Browser; | ||
import com.microsoft.playwright.Playwright; | ||
import org.shakespeareframework.Ability; | ||
|
||
public class BrowseTheWeb implements Ability, AutoCloseable { | ||
|
||
private static final Playwright playwright = Playwright.create(); | ||
|
||
private Browser browser; | ||
|
||
Browser getBrowser() { | ||
if (browser == null) { | ||
this.browser = playwright.firefox().launch(); | ||
} | ||
return browser; | ||
} | ||
|
||
@Override | ||
public void close() { | ||
playwright.close(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
modules/playwrite/src/main/java/org/shakespeareframework/playwrite/package-info.java
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 @@ | ||
/** | ||
* The central class of the selenium package is the {@link | ||
* org.shakespeareframework.playwrite.BrowseTheWeb} Ability. | ||
* | ||
* @see <a | ||
* href="https://shakespeareframework.org/latest/manual/#_browser_automation_with_playwrite"> | ||
* Manual on "Browser Automation with Playwrite"</a> | ||
*/ | ||
package org.shakespeareframework.playwrite; |
15 changes: 15 additions & 0 deletions
15
modules/playwrite/src/test/java/org/shakespeareframework/playwrite/BrowseTheWebTest.java
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,15 @@ | ||
package org.shakespeareframework.playwrite; | ||
|
||
import com.microsoft.playwright.Browser; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class BrowseTheWebTest { | ||
|
||
@Test | ||
void getBrowserTest1() { | ||
var browseTheWeb = new BrowseTheWeb(); | ||
Browser browser = browseTheWeb.getBrowser(); | ||
browser.newContext().newPage().navigate("https://shakespeareframework.org"); | ||
browseTheWeb.close(); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
rootProject.name = 'shakespeare' | ||
|
||
include 'bom' | ||
include 'manual' | ||
include 'modules:core' | ||
include 'modules:selenium' | ||
include 'modules:retrofit' | ||
include 'modules:testutils' | ||
include 'manual' | ||
include 'modules:playwrite' |