diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 16e62ed1..bb9b176d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Test +name: Build & Test on: push: branches: @@ -9,7 +9,7 @@ on: - master - release-* jobs: - build: + dev: timeout-minutes: 30 strategy: fail-fast: false @@ -48,3 +48,44 @@ jobs: 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 }} diff --git a/playwright/src/main/java/com/microsoft/playwright/BrowserType.java b/playwright/src/main/java/com/microsoft/playwright/BrowserType.java index 9aeb726a..1a5a6411 100644 --- a/playwright/src/main/java/com/microsoft/playwright/BrowserType.java +++ b/playwright/src/main/java/com/microsoft/playwright/BrowserType.java @@ -68,6 +68,20 @@ public interface BrowserType { * href="http://peter.sh/experiments/chromium-command-line-switches/">here. */ public List args; + /** + * Chromium distribution channel, one of + * + */ + public String channel; /** * Enable Chromium sandboxing. Defaults to {@code false}. */ @@ -144,6 +158,10 @@ public interface BrowserType { this.args = args; return this; } + public LaunchOptions setChannel(String channel) { + this.channel = channel; + return this; + } public LaunchOptions setChromiumSandbox(boolean chromiumSandbox) { this.chromiumSandbox = chromiumSandbox; return this; @@ -222,6 +240,20 @@ public interface BrowserType { * Toggles bypassing page's Content-Security-Policy. */ public Boolean bypassCSP; + /** + * Chromium distribution channel, one of + * + */ + public String channel; /** * Enable Chromium sandboxing. Defaults to {@code true}. */ @@ -383,6 +415,10 @@ public interface BrowserType { this.bypassCSP = bypassCSP; return this; } + public LaunchPersistentContextOptions setChannel(String channel) { + this.channel = channel; + return this; + } public LaunchPersistentContextOptions setChromiumSandbox(boolean chromiumSandbox) { this.chromiumSandbox = chromiumSandbox; return this; diff --git a/playwright/src/main/java/com/microsoft/playwright/Download.java b/playwright/src/main/java/com/microsoft/playwright/Download.java index 1a087c62..02f4385f 100644 --- a/playwright/src/main/java/com/microsoft/playwright/Download.java +++ b/playwright/src/main/java/com/microsoft/playwright/Download.java @@ -52,19 +52,20 @@ public interface Download { */ InputStream createReadStream(); /** - * Deletes the downloaded file. + * Deletes the downloaded file. Will wait for the download to finish if necessary. */ void delete(); /** - * Returns download error if any. + * Returns download error if any. Will wait for the download to finish if necessary. */ String failure(); /** - * Returns path to the downloaded file in case of successful download. + * Returns path to the downloaded file in case of successful download. The method will wait for the download to finish if + * necessary. */ Path path(); /** - * Saves the download to a user-specified path. + * Saves the download to a user-specified path. It is safe to call this method while the download is still in progress. * * @param path Path where the download should be saved. */ diff --git a/playwright/src/test/java/com/microsoft/playwright/TestAutoClose.java b/playwright/src/test/java/com/microsoft/playwright/TestAutoClose.java index a992ba46..8521bf3e 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestAutoClose.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestAutoClose.java @@ -25,7 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; */ public class TestAutoClose { @Test - void shouldAllowUsingTryWithResources() throws Exception { + void shouldAllowUsingTryWithResources() { try (Playwright playwright = Playwright.create(); Browser browser = Utils.getBrowserTypeFromEnv(playwright).launch(); BrowserContext context = browser.newContext(); diff --git a/playwright/src/test/java/com/microsoft/playwright/TestBase.java b/playwright/src/test/java/com/microsoft/playwright/TestBase.java index b4621ba2..356ec443 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestBase.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestBase.java @@ -51,12 +51,17 @@ public class TestBase { return "firefox".equals(browserType.name()); } + private static String getBrowserChannelFromEnv() { + return System.getenv("BROWSER_CHANNEL"); + } + static BrowserType.LaunchOptions createLaunchOptions() { String headfulEnv = System.getenv("HEADFUL"); headful = headfulEnv != null && !"0".equals(headfulEnv) && !"false".equals(headfulEnv); BrowserType.LaunchOptions options; options = new BrowserType.LaunchOptions(); options.headless = !headful; + options.channel = getBrowserChannelFromEnv(); return options; } diff --git a/playwright/src/test/java/com/microsoft/playwright/TestBrowserContextExposeFunction.java b/playwright/src/test/java/com/microsoft/playwright/TestBrowserContextExposeFunction.java index d2c0ed43..33334e6c 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestBrowserContextExposeFunction.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestBrowserContextExposeFunction.java @@ -88,11 +88,12 @@ public class TestBrowserContextExposeFunction extends TestBase { context.exposeFunction("woof", args -> actualArgs.add(args[0])); context.addInitScript("window['woof']('context')"); Page page = context.newPage(); - page.addInitScript("window['woof']('page')"); + page.evaluate("undefined"); + assertEquals(asList("context"), actualArgs); actualArgs.clear(); + page.addInitScript("window['woof']('page')"); page.reload(); - assertTrue(actualArgs.contains("context")); - assertTrue(actualArgs.contains("page")); + assertEquals(asList("context", "page"), actualArgs); } @Test diff --git a/playwright/src/test/java/com/microsoft/playwright/TestPageKeyboard.java b/playwright/src/test/java/com/microsoft/playwright/TestPageKeyboard.java index ad5ee9d5..e796d0d9 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestPageKeyboard.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestPageKeyboard.java @@ -368,6 +368,8 @@ 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"); diff --git a/scripts/CLI_VERSION b/scripts/CLI_VERSION index 76530a62..e1e1dacd 100644 --- a/scripts/CLI_VERSION +++ b/scripts/CLI_VERSION @@ -1 +1 @@ -1.10.0-next-1615230258000 +1.10.0-next-1616100617000