Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1432b62b84 | |||
| fd87e552f2 | |||
| 0891edd336 |
@@ -1,27 +0,0 @@
|
||||
name: "devrelease:docker"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
jobs:
|
||||
publish-canary-docker:
|
||||
name: "publish to DockerHub"
|
||||
# We use `docker push --all-tags` to push all tags which is a newly addition to docker
|
||||
runs-on: ubuntu-20.04
|
||||
if: github.repository == 'microsoft/playwright-java'
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: azure/docker-login@v1
|
||||
with:
|
||||
login-server: playwright.azurecr.io
|
||||
username: playwright
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
- uses: actions/checkout@v2
|
||||
- name: Build Docker image
|
||||
run: docker build -t playwright-java:localbuild-focal -f Dockerfile.focal .
|
||||
- name: tag & publish
|
||||
run: |
|
||||
./scripts/tag_image_and_push.sh playwright-java:localbuild-focal playwright.azurecr.io/public/playwright/java:next
|
||||
./scripts/tag_image_and_push.sh playwright-java:localbuild-focal playwright.azurecr.io/public/playwright/java:next-focal
|
||||
./scripts/tag_image_and_push.sh playwright-java:localbuild-focal playwright.azurecr.io/public/playwright/java:sha-${{ github.sha }}
|
||||
@@ -1,4 +1,4 @@
|
||||
name: Build & Test
|
||||
name: Test
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
@@ -9,7 +9,7 @@ on:
|
||||
- master
|
||||
- release-*
|
||||
jobs:
|
||||
dev:
|
||||
build:
|
||||
timeout-minutes: 30
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@@ -39,53 +39,3 @@ jobs:
|
||||
run: mvn test --no-transfer-progress
|
||||
env:
|
||||
BROWSER: ${{ matrix.browser }}
|
||||
- name: Test Spring Boot Starter
|
||||
shell: bash
|
||||
env:
|
||||
BROWSER: ${{ matrix.browser }}
|
||||
run: |
|
||||
mvn -B install -D skipTests --no-transfer-progress
|
||||
cd tools/test-spring-boot-starter
|
||||
mvn package -D skipTests --no-transfer-progress
|
||||
java -jar target/test-spring-boot*.jar
|
||||
|
||||
stable:
|
||||
timeout-minutes: 30
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
browser-channel: [chrome]
|
||||
include:
|
||||
- os: windows-latest
|
||||
browser-channel: msedge
|
||||
- os: macos-latest
|
||||
browser-channel: msedge
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: microsoft/playwright-github-action@v1
|
||||
- name: Install Media Pack
|
||||
if: matrix.os == 'windows-latest'
|
||||
shell: powershell
|
||||
run: Install-WindowsFeature Server-Media-Foundation
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
- name: Cache Maven packages
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2
|
||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: ${{ runner.os }}-m2
|
||||
- name: Download drivers
|
||||
shell: bash
|
||||
run: scripts/download_driver_for_all_platforms.sh
|
||||
- name: Build with Maven
|
||||
run: mvn -B package -D skipTests --no-transfer-progress
|
||||
- name: Run tests
|
||||
run: mvn test --no-transfer-progress
|
||||
env:
|
||||
BROWSER: chromium
|
||||
BROWSER_CHANNEL: ${{ matrix.browser-channel }}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
name: Test Docker
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '.github/workflows/test_docker.yml'
|
||||
- 'Dockerfile*'
|
||||
branches:
|
||||
- master
|
||||
- release-*
|
||||
pull_request:
|
||||
paths:
|
||||
- .github/workflows/test_docker.yml
|
||||
- Dockerfile.*
|
||||
- scripts/CLI_VERSION
|
||||
- '**/pom.xml'
|
||||
branches:
|
||||
- master
|
||||
- release-*
|
||||
jobs:
|
||||
test:
|
||||
timeout-minutes: 60
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Build Docker image
|
||||
run: docker build -t playwright-java:localbuild-focal -f Dockerfile.focal .
|
||||
- name: Test
|
||||
run: |
|
||||
CONTAINER_ID="$(docker run --rm --ipc=host -v $(pwd):/root/playwright --name playwright-docker-test -d -t playwright-java:localbuild-focal /bin/bash)"
|
||||
docker exec "${CONTAINER_ID}" /root/playwright/tools/test-local-installation/create_project_and_run_tests.sh
|
||||
+45
-115
@@ -1,141 +1,71 @@
|
||||
FROM ubuntu:focal
|
||||
|
||||
# === GENERATED BROWSER DEPENDENCIES ===
|
||||
# === INSTALL BROWSER DEPENDENCIES ===
|
||||
|
||||
# (generated with ./updateDockerDeps.js)
|
||||
|
||||
# tools
|
||||
# Install WebKit dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
xvfb
|
||||
libwoff1 \
|
||||
libopus0 \
|
||||
libwebp6 \
|
||||
libwebpdemux2 \
|
||||
libenchant1c2a \
|
||||
libgudev-1.0-0 \
|
||||
libsecret-1-0 \
|
||||
libhyphen0 \
|
||||
libgdk-pixbuf2.0-0 \
|
||||
libegl1 \
|
||||
libnotify4 \
|
||||
libxslt1.1 \
|
||||
libevent-2.1-7 \
|
||||
libgles2 \
|
||||
libxcomposite1 \
|
||||
libatk1.0-0 \
|
||||
libatk-bridge2.0-0 \
|
||||
libepoxy0 \
|
||||
libgtk-3-0 \
|
||||
libharfbuzz-icu0
|
||||
|
||||
# chromium
|
||||
# Install gstreamer and plugins to support video playback in WebKit.
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
fonts-liberation\
|
||||
libasound2\
|
||||
libatk-bridge2.0-0\
|
||||
libatk1.0-0\
|
||||
libatspi2.0-0\
|
||||
libcairo2\
|
||||
libcups2\
|
||||
libdbus-1-3\
|
||||
libdrm2\
|
||||
libgbm1\
|
||||
libglib2.0-0\
|
||||
libgtk-3-0\
|
||||
libnspr4\
|
||||
libnss3\
|
||||
libpango-1.0-0\
|
||||
libx11-6\
|
||||
libxcb1\
|
||||
libxcomposite1\
|
||||
libxdamage1\
|
||||
libxext6\
|
||||
libxfixes3\
|
||||
libxrandr2
|
||||
libgstreamer-gl1.0-0 \
|
||||
libgstreamer-plugins-bad1.0-0 \
|
||||
gstreamer1.0-plugins-good \
|
||||
gstreamer1.0-libav
|
||||
|
||||
# firefox
|
||||
# Install Chromium dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
ffmpeg\
|
||||
libatk1.0-0\
|
||||
libcairo-gobject2\
|
||||
libcairo2\
|
||||
libdbus-1-3\
|
||||
libdbus-glib-1-2\
|
||||
libfontconfig1\
|
||||
libfreetype6\
|
||||
libgdk-pixbuf2.0-0\
|
||||
libglib2.0-0\
|
||||
libgtk-3-0\
|
||||
libpango-1.0-0\
|
||||
libpangocairo-1.0-0\
|
||||
libpangoft2-1.0-0\
|
||||
libx11-6\
|
||||
libx11-xcb1\
|
||||
libxcb-shm0\
|
||||
libxcb1\
|
||||
libxcomposite1\
|
||||
libxcursor1\
|
||||
libxdamage1\
|
||||
libxext6\
|
||||
libxfixes3\
|
||||
libxi6\
|
||||
libxrender1\
|
||||
libnss3 \
|
||||
libxss1 \
|
||||
libasound2 \
|
||||
fonts-noto-color-emoji \
|
||||
libxtst6
|
||||
|
||||
# Install Firefox dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libdbus-glib-1-2 \
|
||||
libxt6
|
||||
|
||||
# webkit
|
||||
# Install ffmpeg to bring in audio and video codecs necessary for playing videos in Firefox.
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
gstreamer1.0-libav\
|
||||
gstreamer1.0-plugins-bad\
|
||||
gstreamer1.0-plugins-base\
|
||||
gstreamer1.0-plugins-good\
|
||||
libatk-bridge2.0-0\
|
||||
libatk1.0-0\
|
||||
libcairo2\
|
||||
libegl1\
|
||||
libenchant1c2a\
|
||||
libepoxy0\
|
||||
libfontconfig1\
|
||||
libfreetype6\
|
||||
libgdk-pixbuf2.0-0\
|
||||
libgl1\
|
||||
libgles2\
|
||||
libglib2.0-0\
|
||||
libgstreamer-gl1.0-0\
|
||||
libgstreamer1.0-0\
|
||||
libgtk-3-0\
|
||||
libharfbuzz-icu0\
|
||||
libharfbuzz0b\
|
||||
libhyphen0\
|
||||
libicu66\
|
||||
libjpeg-turbo8\
|
||||
libnotify4\
|
||||
libopenjp2-7\
|
||||
libopus0\
|
||||
libpango-1.0-0\
|
||||
libpng16-16\
|
||||
libsecret-1-0\
|
||||
libsoup2.4-1\
|
||||
libvpx6\
|
||||
libwayland-client0\
|
||||
libwayland-egl1\
|
||||
libwayland-server0\
|
||||
libwebp6\
|
||||
libwebpdemux2\
|
||||
libwoff1\
|
||||
libx11-6\
|
||||
libxcomposite1\
|
||||
libxdamage1\
|
||||
libxkbcommon0\
|
||||
libxml2\
|
||||
libxslt1.1
|
||||
ffmpeg
|
||||
|
||||
# === GENERATED BROWSER DEPENDENCIES END ===
|
||||
# (Optional) Install XVFB if there's a need to run browsers in headful mode
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
xvfb
|
||||
|
||||
# === INSTALL JDK and Maven ===
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
openjdk-11-jdk maven
|
||||
|
||||
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
|
||||
openjdk-8-jdk maven
|
||||
|
||||
# Install utilities required for downloading driver
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
curl unzip
|
||||
|
||||
# === INSTALL playwright maven modules & browsers ===
|
||||
|
||||
# Browsers will remain downloaded in `/ms-playwright`.
|
||||
# Note: make sure to set 777 to the registry so that any user can access
|
||||
# registry.
|
||||
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
|
||||
|
||||
RUN mkdir /ms-playwright && chmod -R 777 $PLAYWRIGHT_BROWSERS_PATH
|
||||
# === INSTALL Playwright-java ===
|
||||
|
||||
RUN mkdir /tmp/pw-java
|
||||
COPY . /tmp/pw-java
|
||||
RUN cd /tmp/pw-java && \
|
||||
./scripts/download_driver_for_all_platforms.sh && \
|
||||
RUN cd /tmp/pw-java && ./scripts/download_driver_for_all_platforms.sh && \
|
||||
mvn install -D skipTests --no-transfer-progress && \
|
||||
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI \
|
||||
-D exec.args="install" -f playwright/pom.xml --no-transfer-progress && \
|
||||
rm -rf /tmp/pw-java
|
||||
|
||||
@@ -11,9 +11,9 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom
|
||||
|
||||
| | Linux | macOS | Windows |
|
||||
| :--- | :---: | :---: | :---: |
|
||||
| Chromium <!-- GEN:chromium-version -->90.0.4421.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| Chromium <!-- GEN:chromium-version -->90.0.4392.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| WebKit <!-- GEN:webkit-version -->14.1<!-- GEN:stop --> | ✅ | ✅ | ✅ |
|
||||
| Firefox <!-- GEN:firefox-version -->86.0b10<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| Firefox <!-- GEN:firefox-version -->85.0b5<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
|
||||
Headless execution is supported for all the browsers on all platforms. Check out [system requirements](https://playwright.dev/#?path=docs/intro.md&q=system-requirements) for details.
|
||||
|
||||
@@ -35,7 +35,7 @@ Playwright requires **Java 8** or newer.
|
||||
|
||||
#### Add Maven dependency
|
||||
|
||||
Playwright is distributed as a set of [Maven](https://maven.apache.org/what-is-maven.html) modules. The easiest way to use it is to add one dependency to your Maven `pom.xml` file as described below. If you're not familiar with Maven please refer to its [documentation](https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html).
|
||||
Playwright is distributed as a set of [Maven](https://maven.apache.org/what-is-maven.html) modules. The easiest way to use it is to add a couple of dependencies to your Maven `pom.xml` file as described below. If you're not familiar with Maven please refer to its [documentation](https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html).
|
||||
|
||||
To run Playwright simply add following dependency to your Maven project:
|
||||
|
||||
@@ -43,13 +43,13 @@ To run Playwright simply add following dependency to your Maven project:
|
||||
<dependency>
|
||||
<groupId>com.microsoft.playwright</groupId>
|
||||
<artifactId>playwright</artifactId>
|
||||
<version>1.9.1-alpha-0</version>
|
||||
<version>0.180.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
#### Is Playwright thread-safe?
|
||||
|
||||
No, Playwright is not thread safe, i.e. all its methods as well as methods on all objects created by it (such as BrowserContext, Browser, Page etc.) are expected to be called on the same thread where Playwright object was created or proper synchronization should be implemented to ensure only one thread calls Playwright methods at any given time. Having said that it's okay to create multiple Playwright instances each on its own thread.
|
||||
No, Playwright is not thread safe, i.e. all its methods as well as methods on all objects created by it (such as BrowserContext, Browser, Page etc.) are expected to be called on the same thread where Playwright object was created or proper synchronization should be implemented to ensure only one thread calls Playwright methods at any given time. Having said that it's okay to create new many Playwright instances each on its own thread.
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -173,9 +173,7 @@ public class InterceptNetworkRequests {
|
||||
|
||||
## Documentation
|
||||
|
||||
Check out our [new documentation site](https://playwright.dev/java)!.
|
||||
|
||||
You can also browse [javadoc online](https://www.javadoc.io/doc/com.microsoft.playwright/playwright/latest/index.html).
|
||||
We are in the process of converting our documentation from the Node.js form to [Javadocs](https://www.javadoc.io/doc/com.microsoft.playwright/playwright/latest/index.html). You can go ahead and use the Node.js [documentation](https://playwright.dev/) since the API is pretty much the same.
|
||||
|
||||
## Contributing
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.microsoft.playwright</groupId>
|
||||
<artifactId>parent-pom</artifactId>
|
||||
<version>1.10.0</version>
|
||||
<version>1.9.1-alpha-0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>driver-bundle</artifactId>
|
||||
|
||||
@@ -57,9 +57,7 @@ public class DriverJar extends Driver {
|
||||
|
||||
private void extractDriverToTempDir() throws URISyntaxException, IOException {
|
||||
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
|
||||
URI originalUri = classloader.getResource("driver/" + platformDir()).toURI();
|
||||
URI uri = maybeExtractNestedJar(originalUri);
|
||||
|
||||
URI uri = classloader.getResource("driver/" + platformDir()).toURI();
|
||||
// Create zip filesystem if loading from jar.
|
||||
try (FileSystem fileSystem = "jar".equals(uri.getScheme()) ? FileSystems.newFileSystem(uri, Collections.emptyMap()) : null) {
|
||||
Path srcRoot = Paths.get(uri);
|
||||
@@ -82,34 +80,12 @@ public class DriverJar extends Driver {
|
||||
}
|
||||
toPath.toFile().deleteOnExit();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to extract driver from " + uri + ", full uri: " + originalUri, e);
|
||||
throw new RuntimeException("Failed to extract driver from " + uri, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private URI maybeExtractNestedJar(final URI uri) throws URISyntaxException {
|
||||
if (!"jar".equals(uri.getScheme())) {
|
||||
return uri;
|
||||
}
|
||||
final String JAR_URL_SEPARATOR = "!/";
|
||||
String[] parts = uri.toString().split("!/");
|
||||
if (parts.length != 3) {
|
||||
return uri;
|
||||
}
|
||||
String innerJar = String.join(JAR_URL_SEPARATOR, parts[0], parts[1]);
|
||||
URI jarUri = new URI(innerJar);
|
||||
try (FileSystem fs = FileSystems.newFileSystem(jarUri, Collections.emptyMap())) {
|
||||
Path fromPath = Paths.get(jarUri);
|
||||
Path toPath = driverTempDir.resolve(fromPath.getFileName().toString());
|
||||
Files.copy(fromPath, toPath);
|
||||
toPath.toFile().deleteOnExit();
|
||||
return new URI("jar:" + toPath.toUri() + JAR_URL_SEPARATOR + parts[2]);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to extract driver's nested .jar from " + jarUri + "; full uri: " + uri, e);
|
||||
}
|
||||
}
|
||||
|
||||
private static String platformDir() {
|
||||
String name = System.getProperty("os.name").toLowerCase();
|
||||
if (name.contains("windows")) {
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.microsoft.playwright</groupId>
|
||||
<artifactId>parent-pom</artifactId>
|
||||
<version>1.10.0</version>
|
||||
<version>1.9.1-alpha-0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>driver</artifactId>
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>examples</artifactId>
|
||||
<version>1.10.0</version>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<name>Playwright Client Examples</name>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
@@ -15,7 +15,7 @@
|
||||
<dependency>
|
||||
<groupId>com.microsoft.playwright</groupId>
|
||||
<artifactId>playwright</artifactId>
|
||||
<version>1.9.1-alpha-0</version>
|
||||
<version>0.190.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.microsoft.playwright</groupId>
|
||||
<artifactId>parent-pom</artifactId>
|
||||
<version>1.10.0</version>
|
||||
<version>1.9.1-alpha-0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>playwright</artifactId>
|
||||
|
||||
@@ -66,7 +66,7 @@ public interface Browser extends AutoCloseable {
|
||||
public Boolean bypassCSP;
|
||||
/**
|
||||
* Emulates {@code "prefers-colors-scheme"} media feature, supported values are {@code "light"}, {@code "dark"}, {@code "no-preference"}. See
|
||||
* {@link Page#emulateMedia Page.emulateMedia()} for more details. Defaults to {@code "light"}.
|
||||
* {@link Page#emulateMedia Page.emulateMedia()} for more details. Defaults to '{@code light}'.
|
||||
*/
|
||||
public ColorScheme colorScheme;
|
||||
/**
|
||||
@@ -124,14 +124,11 @@ public interface Browser extends AutoCloseable {
|
||||
*/
|
||||
public Boolean recordHarOmitContent;
|
||||
/**
|
||||
* Enables <a href="http://www.softwareishard.com/blog/har-12-spec">HAR</a> recording for all pages into the specified HAR
|
||||
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link BrowserContext#close
|
||||
* BrowserContext.close()} for the HAR to be saved.
|
||||
* Path on the filesystem to write the HAR file to.
|
||||
*/
|
||||
public Path recordHarPath;
|
||||
/**
|
||||
* Enables video recording for all pages into the specified directory. If not specified videos are not recorded. Make sure
|
||||
* to call {@link BrowserContext#close BrowserContext.close()} for videos to be saved.
|
||||
* Path to the directory to put videos into.
|
||||
*/
|
||||
public Path recordVideoDir;
|
||||
/**
|
||||
@@ -289,7 +286,7 @@ public interface Browser extends AutoCloseable {
|
||||
public Boolean bypassCSP;
|
||||
/**
|
||||
* Emulates {@code "prefers-colors-scheme"} media feature, supported values are {@code "light"}, {@code "dark"}, {@code "no-preference"}. See
|
||||
* {@link Page#emulateMedia Page.emulateMedia()} for more details. Defaults to {@code "light"}.
|
||||
* {@link Page#emulateMedia Page.emulateMedia()} for more details. Defaults to '{@code light}'.
|
||||
*/
|
||||
public ColorScheme colorScheme;
|
||||
/**
|
||||
@@ -347,14 +344,11 @@ public interface Browser extends AutoCloseable {
|
||||
*/
|
||||
public Boolean recordHarOmitContent;
|
||||
/**
|
||||
* Enables <a href="http://www.softwareishard.com/blog/har-12-spec">HAR</a> recording for all pages into the specified HAR
|
||||
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link BrowserContext#close
|
||||
* BrowserContext.close()} for the HAR to be saved.
|
||||
* Path on the filesystem to write the HAR file to.
|
||||
*/
|
||||
public Path recordHarPath;
|
||||
/**
|
||||
* Enables video recording for all pages into the specified directory. If not specified videos are not recorded. Make sure
|
||||
* to call {@link BrowserContext#close BrowserContext.close()} for videos to be saved.
|
||||
* Path to the directory to put videos into.
|
||||
*/
|
||||
public Path recordVideoDir;
|
||||
/**
|
||||
|
||||
@@ -68,10 +68,6 @@ public interface BrowserType {
|
||||
* href="http://peter.sh/experiments/chromium-command-line-switches/">here</a>.
|
||||
*/
|
||||
public List<String> args;
|
||||
/**
|
||||
* Browser distribution channel.
|
||||
*/
|
||||
public BrowserChannel channel;
|
||||
/**
|
||||
* Enable Chromium sandboxing. Defaults to {@code false}.
|
||||
*/
|
||||
@@ -148,10 +144,6 @@ public interface BrowserType {
|
||||
this.args = args;
|
||||
return this;
|
||||
}
|
||||
public LaunchOptions setChannel(BrowserChannel channel) {
|
||||
this.channel = channel;
|
||||
return this;
|
||||
}
|
||||
public LaunchOptions setChromiumSandbox(boolean chromiumSandbox) {
|
||||
this.chromiumSandbox = chromiumSandbox;
|
||||
return this;
|
||||
@@ -230,17 +222,13 @@ public interface BrowserType {
|
||||
* Toggles bypassing page's Content-Security-Policy.
|
||||
*/
|
||||
public Boolean bypassCSP;
|
||||
/**
|
||||
* Browser distribution channel.
|
||||
*/
|
||||
public BrowserChannel channel;
|
||||
/**
|
||||
* Enable Chromium sandboxing. Defaults to {@code true}.
|
||||
*/
|
||||
public Boolean chromiumSandbox;
|
||||
/**
|
||||
* Emulates {@code "prefers-colors-scheme"} media feature, supported values are {@code "light"}, {@code "dark"}, {@code "no-preference"}. See
|
||||
* {@link Page#emulateMedia Page.emulateMedia()} for more details. Defaults to {@code "light"}.
|
||||
* {@link Page#emulateMedia Page.emulateMedia()} for more details. Defaults to '{@code light}'.
|
||||
*/
|
||||
public ColorScheme colorScheme;
|
||||
/**
|
||||
@@ -345,14 +333,11 @@ public interface BrowserType {
|
||||
*/
|
||||
public Boolean recordHarOmitContent;
|
||||
/**
|
||||
* Enables <a href="http://www.softwareishard.com/blog/har-12-spec">HAR</a> recording for all pages into the specified HAR
|
||||
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link BrowserContext#close
|
||||
* BrowserContext.close()} for the HAR to be saved.
|
||||
* Path on the filesystem to write the HAR file to.
|
||||
*/
|
||||
public Path recordHarPath;
|
||||
/**
|
||||
* Enables video recording for all pages into the specified directory. If not specified videos are not recorded. Make sure
|
||||
* to call {@link BrowserContext#close BrowserContext.close()} for videos to be saved.
|
||||
* Path to the directory to put videos into.
|
||||
*/
|
||||
public Path recordVideoDir;
|
||||
/**
|
||||
@@ -398,10 +383,6 @@ public interface BrowserType {
|
||||
this.bypassCSP = bypassCSP;
|
||||
return this;
|
||||
}
|
||||
public LaunchPersistentContextOptions setChannel(BrowserChannel channel) {
|
||||
this.channel = channel;
|
||||
return this;
|
||||
}
|
||||
public LaunchPersistentContextOptions setChromiumSandbox(boolean chromiumSandbox) {
|
||||
this.chromiumSandbox = chromiumSandbox;
|
||||
return this;
|
||||
|
||||
@@ -52,20 +52,19 @@ public interface Download {
|
||||
*/
|
||||
InputStream createReadStream();
|
||||
/**
|
||||
* Deletes the downloaded file. Will wait for the download to finish if necessary.
|
||||
* Deletes the downloaded file.
|
||||
*/
|
||||
void delete();
|
||||
/**
|
||||
* Returns download error if any. Will wait for the download to finish if necessary.
|
||||
* Returns download error if any.
|
||||
*/
|
||||
String failure();
|
||||
/**
|
||||
* Returns path to the downloaded file in case of successful download. The method will wait for the download to finish if
|
||||
* necessary.
|
||||
* Returns path to the downloaded file in case of successful download.
|
||||
*/
|
||||
Path path();
|
||||
/**
|
||||
* Saves the download to a user-specified path. It is safe to call this method while the download is still in progress.
|
||||
* Saves the download to a user-specified path.
|
||||
*
|
||||
* @param path Path where the download should be saved.
|
||||
*/
|
||||
|
||||
@@ -1334,7 +1334,7 @@ public interface Frame {
|
||||
* Returns the return value of {@code expression} as a {@code JSHandle}.
|
||||
*
|
||||
* <p> The only difference between {@link Frame#evaluate Frame.evaluate()} and {@link Frame#evaluateHandle
|
||||
* Frame.evaluateHandle()} is that {@link Frame#evaluateHandle Frame.evaluateHandle()} returns {@code JSHandle}.
|
||||
* Frame.evaluateHandle()} is that [method: Frame.evaluateHandle{@code ] returns }JSHandle`.
|
||||
*
|
||||
* <p> If the function, passed to the {@link Frame#evaluateHandle Frame.evaluateHandle()}, returns a <a
|
||||
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@link
|
||||
@@ -1367,7 +1367,7 @@ public interface Frame {
|
||||
* Returns the return value of {@code expression} as a {@code JSHandle}.
|
||||
*
|
||||
* <p> The only difference between {@link Frame#evaluate Frame.evaluate()} and {@link Frame#evaluateHandle
|
||||
* Frame.evaluateHandle()} is that {@link Frame#evaluateHandle Frame.evaluateHandle()} returns {@code JSHandle}.
|
||||
* Frame.evaluateHandle()} is that [method: Frame.evaluateHandle{@code ] returns }JSHandle`.
|
||||
*
|
||||
* <p> If the function, passed to the {@link Frame#evaluateHandle Frame.evaluateHandle()}, returns a <a
|
||||
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@link
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
|
||||
package com.microsoft.playwright;
|
||||
|
||||
/**
|
||||
* PlaywrightException is thrown whenever certain operations are terminated abnormally, e.g. browser closes while {@link
|
||||
* Page#evaluate Page.evaluate()} is running. All Playwright exceptions inherit from this class.
|
||||
*/
|
||||
public class PlaywrightException extends RuntimeException {
|
||||
public PlaywrightException(String message) {
|
||||
super(message);
|
||||
|
||||
@@ -65,7 +65,7 @@ public interface Worker {
|
||||
* Worker#evaluate Worker.evaluate()} would wait for the promise to resolve and return its value.
|
||||
*
|
||||
* <p> If the function passed to the {@link Worker#evaluate Worker.evaluate()} returns a non-[Serializable] value, then {@link
|
||||
* Worker#evaluate Worker.evaluate()} returns {@code undefined}. Playwright also supports transferring some additional values
|
||||
* Worker#evaluate Worker.evaluate()} returns {@code undefined}. Playwright also supports transferring some additional values
|
||||
* that are not serializable by {@code JSON}: {@code -0}, {@code NaN}, {@code Infinity}, {@code -Infinity}.
|
||||
*
|
||||
* @param expression JavaScript expression to be evaluated in the browser context. If it looks like a function declaration, it is interpreted
|
||||
@@ -82,7 +82,7 @@ public interface Worker {
|
||||
* Worker#evaluate Worker.evaluate()} would wait for the promise to resolve and return its value.
|
||||
*
|
||||
* <p> If the function passed to the {@link Worker#evaluate Worker.evaluate()} returns a non-[Serializable] value, then {@link
|
||||
* Worker#evaluate Worker.evaluate()} returns {@code undefined}. Playwright also supports transferring some additional values
|
||||
* Worker#evaluate Worker.evaluate()} returns {@code undefined}. Playwright also supports transferring some additional values
|
||||
* that are not serializable by {@code JSON}: {@code -0}, {@code NaN}, {@code Infinity}, {@code -Infinity}.
|
||||
*
|
||||
* @param expression JavaScript expression to be evaluated in the browser context. If it looks like a function declaration, it is interpreted
|
||||
|
||||
@@ -38,7 +38,6 @@ class Serialization {
|
||||
if (gson == null) {
|
||||
gson = new GsonBuilder()
|
||||
.registerTypeAdapter(SameSiteAttribute.class, new SameSiteAdapter().nullSafe())
|
||||
.registerTypeAdapter(BrowserChannel.class, new BrowserChannelSerializer())
|
||||
.registerTypeAdapter(ColorScheme.class, new ColorSchemeAdapter().nullSafe())
|
||||
.registerTypeAdapter(Media.class, new MediaSerializer())
|
||||
.registerTypeAdapter(ScreenshotType.class, new ToLowerCaseSerializer<ScreenshotType>())
|
||||
@@ -49,8 +48,7 @@ class Serialization {
|
||||
.registerTypeAdapter((new TypeToken<List<KeyboardModifier>>(){}).getType(), new KeyboardModifiersSerializer())
|
||||
.registerTypeAdapter(Optional.class, new OptionalSerializer())
|
||||
.registerTypeHierarchyAdapter(JSHandleImpl.class, new HandleSerializer())
|
||||
.registerTypeAdapter((new TypeToken<Map<String, String>>(){}).getType(), new StringMapSerializer())
|
||||
.registerTypeAdapter((new TypeToken<Map<String, Object>>(){}).getType(), new FirefoxUserPrefsSerializer())
|
||||
.registerTypeHierarchyAdapter(Map.class, new StringMapSerializer())
|
||||
.registerTypeAdapter(Path.class, new PathSerializer()).create();
|
||||
}
|
||||
return gson;
|
||||
@@ -276,16 +274,6 @@ class Serialization {
|
||||
}
|
||||
}
|
||||
|
||||
private static class FirefoxUserPrefsSerializer implements JsonSerializer<Map<String, Object>> {
|
||||
@Override
|
||||
public JsonElement serialize(Map<String, Object> src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
if (!"java.util.Map<java.lang.String, java.lang.Object>".equals(typeOfSrc.getTypeName())) {
|
||||
throw new PlaywrightException("Unexpected map type: " + typeOfSrc);
|
||||
}
|
||||
return context.serialize(src, Map.class);
|
||||
}
|
||||
}
|
||||
|
||||
private static class StringMapSerializer implements JsonSerializer<Map<String, String>> {
|
||||
@Override
|
||||
public JsonElement serialize(Map<String, String> src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
@@ -296,13 +284,6 @@ class Serialization {
|
||||
}
|
||||
}
|
||||
|
||||
private static class BrowserChannelSerializer implements JsonSerializer<BrowserChannel> {
|
||||
@Override
|
||||
public JsonElement serialize(BrowserChannel src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
return new JsonPrimitive(src.toString().toLowerCase().replace('_', '-'));
|
||||
}
|
||||
}
|
||||
|
||||
private static class MediaSerializer implements JsonSerializer<Media> {
|
||||
@Override
|
||||
public JsonElement serialize(Media src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.microsoft.playwright.options;
|
||||
|
||||
public enum BrowserChannel {
|
||||
CHROME,
|
||||
CHROME_BETA,
|
||||
CHROME_DEV,
|
||||
CHROME_CANARY,
|
||||
MSEDGE,
|
||||
MSEDGE_BETA,
|
||||
MSEDGE_DEV,
|
||||
MSEDGE_CANARY
|
||||
}
|
||||
@@ -18,11 +18,11 @@ package com.microsoft.playwright.options;
|
||||
|
||||
public class FilePayload {
|
||||
/**
|
||||
* File name
|
||||
* [File] name
|
||||
*/
|
||||
public String name;
|
||||
/**
|
||||
* File type
|
||||
* [File] type
|
||||
*/
|
||||
public String mimeType;
|
||||
/**
|
||||
|
||||
@@ -25,7 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
*/
|
||||
public class TestAutoClose {
|
||||
@Test
|
||||
void shouldAllowUsingTryWithResources() {
|
||||
void shouldAllowUsingTryWithResources() throws Exception {
|
||||
try (Playwright playwright = Playwright.create();
|
||||
Browser browser = Utils.getBrowserTypeFromEnv(playwright).launch();
|
||||
BrowserContext context = browser.newContext();
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.microsoft.playwright;
|
||||
|
||||
import com.microsoft.playwright.options.BrowserChannel;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
@@ -24,8 +23,6 @@ import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.microsoft.playwright.Utils.getBrowserNameFromEnv;
|
||||
|
||||
public class TestBase {
|
||||
static Server server;
|
||||
static Server httpsServer;
|
||||
@@ -43,33 +40,15 @@ public class TestBase {
|
||||
}
|
||||
|
||||
static boolean isChromium() {
|
||||
return "chromium".equals(getBrowserNameFromEnv());
|
||||
return "chromium".equals(browserType.name());
|
||||
}
|
||||
|
||||
static boolean isWebKit() {
|
||||
return "webkit".equals(getBrowserNameFromEnv());
|
||||
return "webkit".equals(browserType.name());
|
||||
}
|
||||
|
||||
static boolean isFirefox() {
|
||||
return "firefox".equals(getBrowserNameFromEnv());
|
||||
}
|
||||
|
||||
private static BrowserChannel getBrowserChannelFromEnv() {
|
||||
String channel = System.getenv("BROWSER_CHANNEL");
|
||||
if (channel == null) {
|
||||
return null;
|
||||
}
|
||||
switch (channel) {
|
||||
case "chrome": return BrowserChannel.CHROME;
|
||||
case "chrome-beta": return BrowserChannel.CHROME_BETA;
|
||||
case "chrome-dev": return BrowserChannel.CHROME_DEV;
|
||||
case "chrome-canary": return BrowserChannel.CHROME_CANARY;
|
||||
case "msedge": return BrowserChannel.MSEDGE;
|
||||
case "msedge-beta": return BrowserChannel.MSEDGE_BETA;
|
||||
case "msedge-dev": return BrowserChannel.MSEDGE_DEV;
|
||||
case "msedge-canary": return BrowserChannel.MSEDGE_CANARY;
|
||||
default: throw new IllegalArgumentException("Unknown BROWSER_CHANNEL " + channel);
|
||||
}
|
||||
return "firefox".equals(browserType.name());
|
||||
}
|
||||
|
||||
static BrowserType.LaunchOptions createLaunchOptions() {
|
||||
@@ -78,7 +57,6 @@ public class TestBase {
|
||||
BrowserType.LaunchOptions options;
|
||||
options = new BrowserType.LaunchOptions();
|
||||
options.headless = !headful;
|
||||
options.channel = getBrowserChannelFromEnv();
|
||||
return options;
|
||||
}
|
||||
|
||||
|
||||
+1
-3
@@ -88,10 +88,8 @@ public class TestBrowserContextExposeFunction extends TestBase {
|
||||
context.exposeFunction("woof", args -> actualArgs.add(args[0]));
|
||||
context.addInitScript("window['woof']('context')");
|
||||
Page page = context.newPage();
|
||||
page.evaluate("undefined");
|
||||
assertEquals(asList("context"), actualArgs);
|
||||
actualArgs.clear();
|
||||
page.addInitScript("window['woof']('page')");
|
||||
actualArgs.clear();
|
||||
page.reload();
|
||||
assertEquals(asList("context", "page"), actualArgs);
|
||||
}
|
||||
|
||||
@@ -39,12 +39,7 @@ public class TestBrowserTypeConnect extends TestBase {
|
||||
void kill() throws InterruptedException {
|
||||
process.destroy();
|
||||
int exitCode = process.waitFor();
|
||||
// FIXME: 2 tests are failing this check on windows:
|
||||
// disconnectedEventShouldBeEmittedWhenBrowserIsClosedOrServerIsClosed
|
||||
// shouldThrowWhenUsedAfterIsConnectedReturnsFalse
|
||||
if (!isWindows) {
|
||||
assertEquals(0, exitCode);
|
||||
}
|
||||
assertEquals(0, exitCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.microsoft.playwright;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledIf;
|
||||
|
||||
import static com.microsoft.playwright.Utils.mapOf;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
public class TestFirefoxLauncher extends TestBase {
|
||||
|
||||
@BeforeAll
|
||||
// Hide base class method to not launch browser.
|
||||
static void launchBrowser() {
|
||||
}
|
||||
|
||||
@Override
|
||||
void createContextAndPage() {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledIf(value="com.microsoft.playwright.TestBase#isFirefox", disabledReason="skip")
|
||||
void shouldPassFirefoxUserPreferences() {
|
||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions().setFirefoxUserPrefs(
|
||||
mapOf(
|
||||
"network.proxy.type", 1,
|
||||
"network.proxy.http", "127.0.0.1",
|
||||
"network.proxy.http_port", 3333));
|
||||
launchBrowser(options);
|
||||
Page page = browser.newPage();
|
||||
try {
|
||||
page.navigate("http://example.com");
|
||||
fail("did not throw");
|
||||
} catch (PlaywrightException e) {
|
||||
assertTrue(e.getMessage().contains("NS_ERROR_PROXY_CONNECTION_REFUSED"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.microsoft.playwright;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static com.microsoft.playwright.Utils.mapOf;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class TestNetworkPostData extends TestBase {
|
||||
@Test
|
||||
void shouldReturnCorrectPostDataBufferForUtf8Body() {
|
||||
page.navigate(server.EMPTY_PAGE);
|
||||
String value = "baẞ";
|
||||
Request request = page.waitForRequest("**", () -> {
|
||||
page.evaluate("({url, value}) => {\n" +
|
||||
" const request = new Request(url, {\n" +
|
||||
" method: 'POST',\n" +
|
||||
" body: JSON.stringify(value),\n" +
|
||||
" });\n" +
|
||||
" request.headers.set('content-type', 'application/json;charset=UTF-8');\n" +
|
||||
" return fetch(request);\n" +
|
||||
"}", mapOf("url", server.PREFIX + "/title.html", "value", value));
|
||||
});
|
||||
assertTrue(Arrays.equals(new Gson().toJson(value).getBytes(StandardCharsets.UTF_8), request.postDataBuffer()));
|
||||
assertEquals(new Gson().toJson(value), request.postData());
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldReturnPostDataWOContentType() {
|
||||
page.navigate(server.EMPTY_PAGE);
|
||||
Request request = page.waitForRequest("**", () -> {
|
||||
page.evaluate("({url}) => {\n" +
|
||||
" const request = new Request(url, {\n" +
|
||||
" method: 'POST',\n" +
|
||||
" body: JSON.stringify({ value: 42 }),\n" +
|
||||
" });\n" +
|
||||
" request.headers.set('content-type', '');\n" +
|
||||
" return fetch(request);\n" +
|
||||
"}", mapOf("url", server.PREFIX + "/title.html"));
|
||||
});
|
||||
assertEquals(new Gson().toJson(mapOf("value", 42)), request.postData());
|
||||
}
|
||||
|
||||
void shouldThrowOnInvalidJSONInPostData() {
|
||||
// Thre is no postDataJSON() in java
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldReturnPostDataForPUTRequests() {
|
||||
page.navigate(server.EMPTY_PAGE);
|
||||
Request request = page.waitForRequest("**", () -> {
|
||||
page.evaluate("({url}) => {\n" +
|
||||
" const request = new Request(url, {\n" +
|
||||
" method: 'PUT',\n" +
|
||||
" body: JSON.stringify({ value: 42 }),\n" +
|
||||
" });\n" +
|
||||
" return fetch(request);\n" +
|
||||
"}", mapOf("url", server.PREFIX + "/title.html"));
|
||||
});
|
||||
assertEquals(new Gson().toJson(mapOf("value", 42)), request.postData());
|
||||
}
|
||||
}
|
||||
@@ -368,8 +368,6 @@ public class TestPageKeyboard extends TestBase {
|
||||
void shouldSupportMacOSShortcuts() {
|
||||
// Test for MacOS only
|
||||
Assumptions.assumeTrue(isMac);
|
||||
// @see https://github.com/microsoft/playwright/issues/5721
|
||||
Assumptions.assumeFalse(isFirefox());
|
||||
page.navigate(server.PREFIX + "/input/textarea.html");
|
||||
ElementHandle textarea = page.querySelector("textarea");
|
||||
textarea.type("some text");
|
||||
|
||||
@@ -84,7 +84,7 @@ public class TestRequestContinue extends TestBase {
|
||||
});
|
||||
page.navigate(server.EMPTY_PAGE);
|
||||
assertNotNull(error[0]);
|
||||
assertTrue(error[0].getMessage().contains("New URL must have same protocol as overridden URL"), error[0].getMessage());
|
||||
assertTrue(error[0].getMessage().contains("New URL must have same protocol as overriden URL"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -104,16 +104,13 @@ class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
static String getBrowserNameFromEnv() {
|
||||
static BrowserType getBrowserTypeFromEnv(Playwright playwright) {
|
||||
String browserName = System.getenv("BROWSER");
|
||||
|
||||
if (browserName == null) {
|
||||
browserName = "chromium";
|
||||
}
|
||||
return browserName;
|
||||
}
|
||||
|
||||
static BrowserType getBrowserTypeFromEnv(Playwright playwright) {
|
||||
String browserName = getBrowserNameFromEnv();
|
||||
switch (browserName) {
|
||||
case "webkit":
|
||||
return playwright.webkit();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.microsoft.playwright</groupId>
|
||||
<artifactId>parent-pom</artifactId>
|
||||
<version>1.10.0</version>
|
||||
<version>1.9.1-alpha-0</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Playwright Parent Project</name>
|
||||
<description>Java library to automate Chromium, Firefox and WebKit with a single API.
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
1.10.0
|
||||
1.9.2
|
||||
|
||||
@@ -14,15 +14,12 @@ trap "cd $(pwd -P)" EXIT
|
||||
cd "$(dirname $0)/.."
|
||||
|
||||
VERSION=$1
|
||||
POM_FILES=(
|
||||
pom.xml
|
||||
tools/api-generator/pom.xml
|
||||
tools/update-docs-version/pom.xml
|
||||
tools/test-spring-boot-starter/pom.xml
|
||||
examples/pom.xml
|
||||
)
|
||||
|
||||
for name in ${POM_FILES[*]};
|
||||
do
|
||||
mvn versions:set -D newVersion=$VERSION -f $name
|
||||
done
|
||||
mvn versions:set -DnewVersion=$VERSION
|
||||
|
||||
cd tools/api-generator
|
||||
mvn versions:set -DnewVersion=$VERSION
|
||||
|
||||
cd -
|
||||
cd tools/update-docs-version
|
||||
mvn versions:set -DnewVersion=$VERSION
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "-- tagging: $2"
|
||||
docker tag $1 $2
|
||||
docker push $2
|
||||
@@ -10,7 +10,7 @@ cd "$(dirname $0)/.."
|
||||
./scripts/generate_api.sh
|
||||
|
||||
# Built from source and do local install.
|
||||
mvn clean install --no-transfer-progress -D skipTests
|
||||
mvn clean install --no-transfer-progress -DskipTests
|
||||
|
||||
echo "Updating browser versions in README.md"
|
||||
mvn compile exec:java --f ./tools/update-docs-version -D exec.mainClass=com.microsoft.playwright.tools.UpdateBrowserVersions
|
||||
mvn exec:java --f ./tools/update-docs-version -Dexec.mainClass=com.microsoft.playwright.tools.UpdateBrowserVersions
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.microsoft.playwright</groupId>
|
||||
<artifactId>api-generator</artifactId>
|
||||
<version>1.10.0</version>
|
||||
<version>1.9.1-alpha-0</version>
|
||||
<name>Playwright - API Generator</name>
|
||||
<description>
|
||||
This is an internal module used to generate Java API from the upstream Playwright
|
||||
|
||||
@@ -1039,7 +1039,7 @@ public class ApiGenerator {
|
||||
for (JsonElement entry: api) {
|
||||
String name = entry.getAsJsonObject().get("name").getAsString();
|
||||
// We write this one manually.
|
||||
if (asList("PlaywrightException", "TimeoutError").contains(name)) {
|
||||
if ("TimeoutError".equals(name)) {
|
||||
continue;
|
||||
}
|
||||
List<String> lines = new ArrayList<>();
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set +x
|
||||
|
||||
trap "cd $(pwd -P)" EXIT
|
||||
cd "$(dirname $0)"
|
||||
|
||||
|
||||
PROJECT_DIR=$(mktemp -d)
|
||||
echo "Creating project in $PROJECT_DIR"
|
||||
cp -R . $PROJECT_DIR
|
||||
cp -R ../../driver-bundle/src/test/ $PROJECT_DIR/src/
|
||||
cp -R ../../playwright/src/test/ $PROJECT_DIR/src/
|
||||
cd $PROJECT_DIR
|
||||
|
||||
mvn test --no-transfer-progress
|
||||
|
||||
rm -rf $PROJECT_DIR
|
||||
@@ -1,61 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.microsoft.playwright</groupId>
|
||||
<artifactId>test-local-installation</artifactId>
|
||||
<version>1.10.0-SNAPSHOT</version>
|
||||
<name>Test local installation</name>
|
||||
<description>Runs Playwright test suite (copied from playwright module) against locally cached Playwright</description>
|
||||
<properties>
|
||||
<compiler.version>1.8</compiler.version>
|
||||
<gson.version>2.8.6</gson.version>
|
||||
<junit.version>5.7.0</junit.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<websocket.version>1.5.1</websocket.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.microsoft.playwright</groupId>
|
||||
<artifactId>playwright</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>${gson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.java-websocket</groupId>
|
||||
<artifactId>Java-WebSocket</artifactId>
|
||||
<version>${websocket.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>${compiler.version}</source>
|
||||
<target>${compiler.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M5</version>
|
||||
<configuration>
|
||||
<redirectTestOutputToFile>true</redirectTestOutputToFile>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -1,2 +0,0 @@
|
||||
This derictory is populated with test files from playwright and playwright-driver projects. They are copied
|
||||
here on each test run.
|
||||
@@ -1,36 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.4.3</version>
|
||||
</parent>
|
||||
<groupId>com.microsoft.playwright</groupId>
|
||||
<artifactId>test-spring-boot-starter</artifactId>
|
||||
<version>1.10.0</version>
|
||||
<name>Test Playwright With Spring Boot</name>
|
||||
<properties>
|
||||
<spring.version>2.4.3</spring.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.microsoft.playwright</groupId>
|
||||
<artifactId>playwright</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
package com.microsoft.playwright.springboottest;
|
||||
|
||||
import com.microsoft.playwright.*;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class TestApp implements CommandLineRunner {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(TestApp.class, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
try (Playwright playwright = Playwright.create()) {
|
||||
BrowserType browserType = getBrowserTypeFromEnv(playwright);
|
||||
System.out.println("Running test with " + browserType.name());
|
||||
Browser browser = browserType.launch();
|
||||
BrowserContext context = browser.newContext();
|
||||
Page page = context.newPage();
|
||||
System.out.println(page.evaluate("'SUCCESS: did evaluate in page'"));
|
||||
}
|
||||
}
|
||||
|
||||
static BrowserType getBrowserTypeFromEnv(Playwright playwright) {
|
||||
String browserName = System.getenv("BROWSER");
|
||||
|
||||
if (browserName == null) {
|
||||
browserName = "chromium";
|
||||
}
|
||||
|
||||
switch (browserName) {
|
||||
case "webkit":
|
||||
return playwright.webkit();
|
||||
case "firefox":
|
||||
return playwright.firefox();
|
||||
case "chromium":
|
||||
return playwright.chromium();
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown browser: " + browserName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.microsoft.playwright</groupId>
|
||||
<artifactId>update-version</artifactId>
|
||||
<version>1.10.0</version>
|
||||
<version>1.9.1-alpha-0</version>
|
||||
<name>Playwright - Update Version in Documentation</name>
|
||||
<description>
|
||||
This is an internal module used to update versions in the documentation based on
|
||||
@@ -38,12 +38,4 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>snapshots-repo</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
<releases><enabled>false</enabled></releases>
|
||||
<snapshots><enabled>true</enabled></snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
||||
|
||||
Reference in New Issue
Block a user