question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Playwright cannot download the browsers automatically

See original GitHub issue

I’m trying to use Playwright in a Java EE environment with Zulu 11 and I always get this error messaged when launching chromium.

com.microsoft.playwright.PlaywrightException: Error {
  message='Failed to launch chromium because executable doesn't exist at C:\Users\Alex\AppData\Local\ms-playwright\chromium-857950\chrome-win\chrome.exe
Try re-installing playwright with "npm install playwright"
  name='Error
  stack='Error: Failed to launch chromium because executable doesn't exist at C:\Users\Alex\AppData\Local\ms-playwright\chromium-857950\chrome-win\chrome.exe
Try re-installing playwright with "npm install playwright"
    at Chromium._launchProcess (C:\Users\Alex\AppData\Local\Temp\playwright-java-12834975463618432611\package\lib\server\browserType.js:174:19)
    at async Chromium._innerLaunch (C:\Users\Alex\AppData\Local\Temp\playwright-java-12834975463618432611\package\lib\server\browserType.js:110:62)
    at async ProgressController.run (C:\Users\Alex\AppData\Local\Temp\playwright-java-12834975463618432611\package\lib\server\progress.js:79:28)
    at async Chromium.launch (C:\Users\Alex\AppData\Local\Temp\playwright-java-12834975463618432611\package\lib\server\browserType.js:78:25)
    at async BrowserTypeDispatcher.launch (C:\Users\Alex\AppData\Local\Temp\playwright-java-12834975463618432611\package\lib\dispatchers\browserTypeDispatcher.js:30:25)
    at async DispatcherConnection.dispatch (C:\Users\Alex\AppData\Local\Temp\playwright-java-12834975463618432611\package\lib\dispatchers\dispatcher.js:181:28)
}
    at com.microsoft.playwright.impl.WaitableResult.get(WaitableResult.java:54)
    at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:88)
    at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:96)
    at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:79)
    at com.microsoft.playwright.impl.BrowserTypeImpl.launchImpl(BrowserTypeImpl.java:49)
    at com.microsoft.playwright.impl.BrowserTypeImpl.lambda$launch$0(BrowserTypeImpl.java:41)
    at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47)
    at com.microsoft.playwright.impl.BrowserTypeImpl.launch(BrowserTypeImpl.java:41)
    at com.microsoft.playwright.impl.BrowserTypeImpl.launch(BrowserTypeImpl.java:34)
    at com.microsoft.playwright.BrowserType.launch(BrowserType.java:601)
    at de.symeda.sormas.ui.labmessage.LabMessageController.convertToPdf(LabMessageController.java:965)
    at de.symeda.sormas.ui.labmessage.LabMessageController.downloadLabMessage(LabMessageController.java:941)
    at de.symeda.sormas.ui.labmessage.LabMessageGrid.lambda$buildDownloadButton$c7abbaac$1(LabMessageGrid.java:177)
    at com.vaadin.server.StreamResource.getStream(StreamResource.java:143)
    at com.vaadin.server.FileDownloader.handleConnectorRequest(FileDownloader.java:167)
    at com.vaadin.server.ConnectorResourceHandler.handleRequest(ConnectorResourceHandler.java:90)
    at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1608)
    at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:448)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1628)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:339)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:209)
    at de.symeda.sormas.ui.SessionFilter.lambda$doFilter$2(SessionFilter.java:72)
    at de.symeda.sormas.ui.SessionFilterBean.doFilter(SessionFilterBean.java:37)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:588)
    at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:408)
    at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4791)
    at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:665)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:836)
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:615)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:140)
    at jdk.internal.reflect.GeneratedMethodAccessor1707.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:895)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:835)
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:615)
    at org.jboss.weld.module.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:72)
    at org.jboss.weld.module.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:52)
    at jdk.internal.reflect.GeneratedMethodAccessor1687.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:895)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:835)
    at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:374)
    at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4763)
    at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4751)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:90)
    at com.sun.proxy.$Proxy2418.doFilter(Unknown Source)
    at de.symeda.sormas.ui.__EJB31_Generated__SessionFilterBean__Intf____Bean__.doFilter(Unknown Source)
    at de.symeda.sormas.ui.SessionFilter.doFilter(SessionFilter.java:65)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:251)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:209)
    at de.symeda.sormas.ui.Slf4jMdcFilter.doFilter(Slf4jMdcFilter.java:29)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:251)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:209)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:755)
    at org.apache.catalina.core.StandardPipeline.doChainInvoke(StandardPipeline.java:579)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:371)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:238)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:520)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:217)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:182)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:156)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:218)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:524)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:89)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:94)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:33)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:114)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: com.microsoft.playwright.impl.DriverException: Error {
  message='Failed to launch chromium because executable doesn't exist at C:\Users\Alex\AppData\Local\ms-playwright\chromium-857950\chrome-win\chrome.exe
Try re-installing playwright with "npm install playwright"
  name='Error
  stack='Error: Failed to launch chromium because executable doesn't exist at C:\Users\Alex\AppData\Local\ms-playwright\chromium-857950\chrome-win\chrome.exe
Try re-installing playwright with "npm install playwright"
    at Chromium._launchProcess (C:\Users\Alex\AppData\Local\Temp\playwright-java-12834975463618432611\package\lib\server\browserType.js:174:19)
    at async Chromium._innerLaunch (C:\Users\Alex\AppData\Local\Temp\playwright-java-12834975463618432611\package\lib\server\browserType.js:110:62)
    at async ProgressController.run (C:\Users\Alex\AppData\Local\Temp\playwright-java-12834975463618432611\package\lib\server\progress.js:79:28)
    at async Chromium.launch (C:\Users\Alex\AppData\Local\Temp\playwright-java-12834975463618432611\package\lib\server\browserType.js:78:25)
    at async BrowserTypeDispatcher.launch (C:\Users\Alex\AppData\Local\Temp\playwright-java-12834975463618432611\package\lib\dispatchers\browserTypeDispatcher.js:30:25)
    at async DispatcherConnection.dispatch (C:\Users\Alex\AppData\Local\Temp\playwright-java-12834975463618432611\package\lib\dispatchers\dispatcher.js:181:28)
}
    at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:209)
    at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:189)
    at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:86)
    ... 87 more
]]

I tried changing the path for browser download using the Environment Variable PLAYWRIGHT_BROWSERS_PATH but still the script was unable to download them.

Any idea what might be wrong? Or any suggestion how can I debug the download script?

Environment Specifications

OS: Windows 10 JDK: Zulu 11 Server: Payara 5

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
vidi42commented, May 5, 2021

Can you delete C:\Users\Alex\AppData\Local\ms-playwright\ altogether, run playwright again and see what’s inside?

Did that and still the same result. Just the .links directory was created.

You just add playwright dependency to your pom.xml (i.e. you don’t build it from sources), correct?

Exactly

Another idea, can you run the following in terminal:

Running the command works and it downloads the browsers.


The issue seems to be related to how calling the install process works in a Java Enterprise environment.

Is seems that the download fails in the com.microsoft.playwright.impl.DriverJar#installBrowsers method when the external process is called

 ProcessBuilder pb = new ProcessBuilder(driver.toString(), "install");
 pb.redirectError(ProcessBuilder.Redirect.INHERIT);
 pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
 Process p = pb.start();
 boolean result = p.waitFor(10, TimeUnit.MINUTES);

Using the ProcessBuilder.Redirect.INHERIT reuses the server’s logging system. However on Windows at least I suspect that the log files are locked by the master process so the child process (playwright.cmd install) fails when trying to access those files.

I validated this assumption by running during debug the following line

pb.redirectError(File.createTempFile("playwright",".error"))

thus changing the stderr for the external process which then worked and the browsers were downloaded. The process also created an empty playwright161449457654957299.error file (sometimes with a few empty lines in it).

I’m now trying to figure out how to pass from our code to the external process a different stderr path which it can inherit so it works.

0reactions
yury-scommented, Jun 15, 2021

Closing as the discussion has stalled.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't download file with Playwright Chromium or Webkit
I want to do it only with playwright 1.22. I tried to do it with chromium browser, but it fails. Also it doesn't...
Read more >
Browser.Playwright — RPA Framework documentation
New Playwright based browser automation library. ... If the file URL cannot be found (the download is triggered by event handlers) use Wait ......
Read more >
Launching Browsers | Cypress Documentation
Cypress automatically detects available browsers on your OS. ... We host chromium.cypress.io with links to download a specific released version of Chrome ...
Read more >
How to test web applications with Playwright and C# .NET
Playwright, on the other hand, automatically install the latest browsers for you and Playwright doesn't use web drivers, so you don't have ...
Read more >
How to Fix the NET::ERR_CERT_AUTHORITY_INVALID Error
Despite its intimidating name, the invalid certificate authority error isn't something you should panic about. Simply put, your browser doesn't ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found