Compare commits
6 Commits
release-1.62
...
v1.11.1
| Author | SHA1 | Date | |
|---|---|---|---|
| dfd62f06b5 | |||
| 7fb2ff34c0 | |||
| 0585e0d108 | |||
| 48d95a6543 | |||
| 74bf6637f3 | |||
| 7f3ecd83b9 |
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.microsoft.playwright</groupId>
|
<groupId>com.microsoft.playwright</groupId>
|
||||||
<artifactId>parent-pom</artifactId>
|
<artifactId>parent-pom</artifactId>
|
||||||
<version>1.11.0-SNAPSHOT</version>
|
<version>1.11.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>driver-bundle</artifactId>
|
<artifactId>driver-bundle</artifactId>
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import com.microsoft.playwright.impl.Driver;
|
import com.microsoft.playwright.impl.Driver;
|
||||||
import com.microsoft.playwright.impl.StreamRedirectThread;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@@ -37,13 +36,11 @@ public class TestInstall {
|
|||||||
assertTrue(Files.exists(cli));
|
assertTrue(Files.exists(cli));
|
||||||
|
|
||||||
ProcessBuilder pb = new ProcessBuilder(cli.toString(), "install");
|
ProcessBuilder pb = new ProcessBuilder(cli.toString(), "install");
|
||||||
|
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
|
||||||
|
pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
|
||||||
Process p = pb.start();
|
Process p = pb.start();
|
||||||
StreamRedirectThread stdoutThread = new StreamRedirectThread(p.getInputStream(), System.out);
|
|
||||||
StreamRedirectThread stderrThread = new StreamRedirectThread(p.getErrorStream(), System.err);
|
|
||||||
boolean result = p.waitFor(1, TimeUnit.MINUTES);
|
boolean result = p.waitFor(1, TimeUnit.MINUTES);
|
||||||
assertTrue(result, "Timed out waiting for browsers to install");
|
assertTrue(result, "Timed out waiting for browsers to install");
|
||||||
stderrThread.terminateAndJoin();
|
|
||||||
stdoutThread.terminateAndJoin();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
assertNull(e);
|
assertNull(e);
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.microsoft.playwright</groupId>
|
<groupId>com.microsoft.playwright</groupId>
|
||||||
<artifactId>parent-pom</artifactId>
|
<artifactId>parent-pom</artifactId>
|
||||||
<version>1.11.0-SNAPSHOT</version>
|
<version>1.11.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>driver</artifactId>
|
<artifactId>driver</artifactId>
|
||||||
|
|||||||
@@ -1,69 +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.impl;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
|
|
||||||
// We manually copy stderr and stdout from child process as INHERIT for err/out streams
|
|
||||||
// doesn't work well in Java Enterprise, see
|
|
||||||
// https://github.com/microsoft/playwright-java/issues/418#issuecomment-832650650
|
|
||||||
public class StreamRedirectThread extends Thread {
|
|
||||||
private final InputStream from;
|
|
||||||
private final OutputStream to;
|
|
||||||
private volatile boolean terminated;
|
|
||||||
|
|
||||||
public StreamRedirectThread(InputStream from, OutputStream to) {
|
|
||||||
this.from = from;
|
|
||||||
this.to = to;
|
|
||||||
start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
byte[] buffer = new byte[1<<14];
|
|
||||||
try {
|
|
||||||
while (true) {
|
|
||||||
while (from.available() != 0) {
|
|
||||||
int len = from.read(buffer);
|
|
||||||
if (len != -1) {
|
|
||||||
to.write(buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (terminated) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Thread.sleep(100);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace(System.err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void terminateAndJoin() {
|
|
||||||
terminated = true;
|
|
||||||
try {
|
|
||||||
join();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace(System.err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>org.example</groupId>
|
<groupId>org.example</groupId>
|
||||||
<artifactId>examples</artifactId>
|
<artifactId>examples</artifactId>
|
||||||
<version>1.11.0-SNAPSHOT</version>
|
<version>1.11.1</version>
|
||||||
<name>Playwright Client Examples</name>
|
<name>Playwright Client Examples</name>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.microsoft.playwright</groupId>
|
<groupId>com.microsoft.playwright</groupId>
|
||||||
<artifactId>parent-pom</artifactId>
|
<artifactId>parent-pom</artifactId>
|
||||||
<version>1.11.0-SNAPSHOT</version>
|
<version>1.11.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>playwright</artifactId>
|
<artifactId>playwright</artifactId>
|
||||||
|
|||||||
@@ -27,29 +27,21 @@ import java.util.concurrent.TimeUnit;
|
|||||||
|
|
||||||
public class PlaywrightImpl extends ChannelOwner implements Playwright {
|
public class PlaywrightImpl extends ChannelOwner implements Playwright {
|
||||||
private Process driverProcess;
|
private Process driverProcess;
|
||||||
private StreamRedirectThread stderrThread;
|
|
||||||
|
|
||||||
public static PlaywrightImpl create() {
|
public static PlaywrightImpl create() {
|
||||||
StreamRedirectThread stderrThread = null;
|
|
||||||
try {
|
try {
|
||||||
Path driver = Driver.ensureDriverInstalled();
|
Path driver = Driver.ensureDriverInstalled();
|
||||||
ProcessBuilder pb = new ProcessBuilder(driver.toString(), "run-driver");
|
ProcessBuilder pb = new ProcessBuilder(driver.toString(), "run-driver");
|
||||||
|
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
|
||||||
// pb.environment().put("DEBUG", "pw:pro*");
|
// pb.environment().put("DEBUG", "pw:pro*");
|
||||||
Process p = pb.start();
|
Process p = pb.start();
|
||||||
stderrThread = new StreamRedirectThread(p.getErrorStream(), System.err);
|
|
||||||
Connection connection = new Connection(new PipeTransport(p.getInputStream(), p.getOutputStream()));
|
Connection connection = new Connection(new PipeTransport(p.getInputStream(), p.getOutputStream()));
|
||||||
PlaywrightImpl result = (PlaywrightImpl) connection.waitForObjectWithKnownName("Playwright");
|
PlaywrightImpl result = (PlaywrightImpl) connection.waitForObjectWithKnownName("Playwright");
|
||||||
result.driverProcess = p;
|
result.driverProcess = p;
|
||||||
result.stderrThread = stderrThread;
|
|
||||||
stderrThread = null;
|
|
||||||
result.initSharedSelectors(null);
|
result.initSharedSelectors(null);
|
||||||
return result;
|
return result;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new PlaywrightException("Failed to launch driver", e);
|
throw new PlaywrightException("Failed to launch driver", e);
|
||||||
} finally {
|
|
||||||
if (stderrThread != null) {
|
|
||||||
stderrThread.terminateAndJoin();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +103,6 @@ public class PlaywrightImpl extends ChannelOwner implements Playwright {
|
|||||||
if (!didClose) {
|
if (!didClose) {
|
||||||
System.err.println("WARNING: Timed out while waiting for driver process to exit");
|
System.err.println("WARNING: Timed out while waiting for driver process to exit");
|
||||||
}
|
}
|
||||||
stderrThread.terminateAndJoin();
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new PlaywrightException("Failed to terminate", e);
|
throw new PlaywrightException("Failed to terminate", e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ class Utils {
|
|||||||
.registerTypeAdapter(Optional.class, new OptionalSerializer())
|
.registerTypeAdapter(Optional.class, new OptionalSerializer())
|
||||||
.create();
|
.create();
|
||||||
String json = gson.toJson(f);
|
String json = gson.toJson(f);
|
||||||
System.err.println("json = " + json);
|
|
||||||
return gson.fromJson(json, t);
|
return gson.fromJson(json, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,11 @@ package com.microsoft.playwright;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.io.TempDir;
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
@@ -101,4 +104,25 @@ public class TestScreencast extends TestBase {
|
|||||||
Path videoPath = page.video().path();
|
Path videoPath = page.video().path();
|
||||||
assertFalse(Files.exists(videoPath));
|
assertFalse(Files.exists(videoPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldWaitForVideoFinishWhenPageIsClosed(@TempDir Path videosDir) throws IOException {
|
||||||
|
try (Browser browser = browserType.launch(createLaunchOptions())) {
|
||||||
|
BrowserContext context = browser.newContext(
|
||||||
|
new Browser.NewContextOptions()
|
||||||
|
.setRecordVideoDir(videosDir)
|
||||||
|
.setRecordVideoSize(320, 240)
|
||||||
|
.setViewportSize(320, 240));
|
||||||
|
Page page = context.newPage();
|
||||||
|
page.evaluate("() => document.body.style.backgroundColor = 'red'");
|
||||||
|
page.waitForTimeout(500);
|
||||||
|
// First close page manually.
|
||||||
|
page.close();
|
||||||
|
context.close();
|
||||||
|
}
|
||||||
|
List<Path> files = Files.list(videosDir).collect(Collectors.toList());
|
||||||
|
assertEquals(1, files.size());
|
||||||
|
assertTrue(Files.exists(files.get(0)));
|
||||||
|
assertTrue(Files.size(files.get(0)) > 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.microsoft.playwright</groupId>
|
<groupId>com.microsoft.playwright</groupId>
|
||||||
<artifactId>parent-pom</artifactId>
|
<artifactId>parent-pom</artifactId>
|
||||||
<version>1.11.0-SNAPSHOT</version>
|
<version>1.11.1</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>Playwright Parent Project</name>
|
<name>Playwright Parent Project</name>
|
||||||
<description>Java library to automate Chromium, Firefox and WebKit with a single API.
|
<description>Java library to automate Chromium, Firefox and WebKit with a single API.
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
1.11.0-1620331022000
|
1.11.1-1621490832000
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.microsoft.playwright</groupId>
|
<groupId>com.microsoft.playwright</groupId>
|
||||||
<artifactId>api-generator</artifactId>
|
<artifactId>api-generator</artifactId>
|
||||||
<version>1.11.0-SNAPSHOT</version>
|
<version>1.11.1</version>
|
||||||
<name>Playwright - API Generator</name>
|
<name>Playwright - API Generator</name>
|
||||||
<description>
|
<description>
|
||||||
This is an internal module used to generate Java API from the upstream Playwright
|
This is an internal module used to generate Java API from the upstream Playwright
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.microsoft.playwright</groupId>
|
<groupId>com.microsoft.playwright</groupId>
|
||||||
<artifactId>test-local-installation</artifactId>
|
<artifactId>test-local-installation</artifactId>
|
||||||
<version>1.11.0-SNAPSHOT</version>
|
<version>1.11.1</version>
|
||||||
<name>Test local installation</name>
|
<name>Test local installation</name>
|
||||||
<description>Runs Playwright test suite (copied from playwright module) against locally cached Playwright</description>
|
<description>Runs Playwright test suite (copied from playwright module) against locally cached Playwright</description>
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<groupId>com.microsoft.playwright</groupId>
|
<groupId>com.microsoft.playwright</groupId>
|
||||||
<artifactId>test-spring-boot-starter</artifactId>
|
<artifactId>test-spring-boot-starter</artifactId>
|
||||||
<version>1.11.0-SNAPSHOT</version>
|
<version>1.11.1</version>
|
||||||
<name>Test Playwright With Spring Boot</name>
|
<name>Test Playwright With Spring Boot</name>
|
||||||
<properties>
|
<properties>
|
||||||
<spring.version>2.4.3</spring.version>
|
<spring.version>2.4.3</spring.version>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.microsoft.playwright</groupId>
|
<groupId>com.microsoft.playwright</groupId>
|
||||||
<artifactId>update-version</artifactId>
|
<artifactId>update-version</artifactId>
|
||||||
<version>1.11.0-SNAPSHOT</version>
|
<version>1.11.1</version>
|
||||||
<name>Playwright - Update Version in Documentation</name>
|
<name>Playwright - Update Version in Documentation</name>
|
||||||
<description>
|
<description>
|
||||||
This is an internal module used to update versions in the documentation based on
|
This is an internal module used to update versions in the documentation based on
|
||||||
|
|||||||
Reference in New Issue
Block a user