microsoft / playwright-java

Java version of the Playwright testing and automation library
https://playwright.dev/java/
Apache License 2.0
1.07k stars 195 forks source link

[Bug]: Failed to install browsers, exit code: 1 #1571

Closed yidasanqian closed 2 months ago

yidasanqian commented 2 months ago

Version

1.41.0

Steps to reproduce

 try (Playwright playwright = Playwright.create();
                     Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setHeadless(true))) {

                    BrowserContext context = browser.newContext(
                            new Browser.NewContextOptions()
                                    .setIgnoreHTTPSErrors(true)
                                    .setUserAgent(ua)
                    );
                    Page page = context.newPage();
                    Response response = page.navigate(url, new Page.NavigateOptions().setReferer(url).setWaitUntil(WaitUntilState.DOMCONTENTLOADED));
                    if (response.ok()) {
                        webPageResult.setContent(Jsoup.clean(response.text(), safelist));
                    }                
                    context.close();
                }

Expected behavior

Normal navigation URL

Actual behavior

Download driver failed

Additional context

        at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
        at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
        at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:175)
Caused by: java.lang.RuntimeException: Failed to create driver
        at com.microsoft.playwright.impl.driver.Driver.createAndInstall(Driver.java:105)
        at com.microsoft.playwright.impl.driver.Driver.ensureDriverInstalled(Driver.java:57)
        at com.microsoft.playwright.impl.PlaywrightImpl.createImpl(PlaywrightImpl.java:45)
        at com.microsoft.playwright.impl.PlaywrightImpl.create(PlaywrightImpl.java:35)
        at com.microsoft.playwright.Playwright.create(Playwright.java:110)
        at com.microsoft.playwright.Playwright.create(Playwright.java:114)
        at com.toowe.enterprise.core.app.searchapp.service.impl.WebSearchServiceImpl.lambda$spiderWebContent$2(WebSearchServiceImpl.java:571)
        at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1640)
        ... 5 common frames omitted
Caused by: java.lang.RuntimeException: Failed to install browsers, exit code: 1
        at com.microsoft.playwright.impl.driver.jar.DriverJar.installBrowsers(DriverJar.java:100)
        at com.microsoft.playwright.impl.driver.jar.DriverJar.initialize(DriverJar.java:69)
        at com.microsoft.playwright.impl.driver.Driver.initialize(Driver.java:64)
        at com.microsoft.playwright.impl.driver.Driver.createAndInstall(Driver.java:101)
        ... 12 common frames omitted

Environment

mxschmitt commented 2 months ago

This Docker image is based on Amazon Linux 2 which is not supported. We only support Debian and Ubuntu as of today. See here for a full list of supported operating systems (with versions): https://playwright.dev/java/docs/intro#system-requirements

If you are using Docker, you can use our official image: https://playwright.dev/java/docs/docker