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]: Browsers are not working #1620

Closed Maxim1-1 closed 18 hours ago

Maxim1-1 commented 4 days ago

Version

1.45

Steps to reproduce

  1. Clone the repository https://github.com/Maxim1-1/Playwright
  2. Replace line 13 with "Browser browser = playwright.firefox().launch(new Browser Type.Launch Options().set Headless(false));"
  3. Run the program

Expected behavior

the firefox browser window has opened

Actual behavior

at org.example.Main.main(Main.java:13)

Caused by: com.microsoft.playwright.impl.DriverException: Error { message='Executable doesn't exist at C:\Users{max}\AppData\Local\ms-playwright\firefox-1454\firefox\firefox.exe ╔════════════════════════════════════════════════════════════════════════════════════════════╗ ║ Looks like Playwright was just installed or updated. ║ ║ Please run the following command to download new browsers: ║ ║ ║ ║ mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install" ║ ║ ║ ║ <3 Playwright Team ║ ╚════════════════════════════════════════════════════════════════════════════════════════════╝ name='Error stack='Error: Executable doesn't exist at C:\Users{max}\AppData\Local\ms-playwright\firefox-1454\firefox\firefox.exe ╔════════════════════════════════════════════════════════════════════════════════════════════╗ ║ Looks like Playwright was just installed or updated. ║ ║ Please run the following command to download new browsers: ║ ║ ║ ║ mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install" ║ ║ ║ ║ <3 Playwright Team ║ ╚════════════════════════════════════════════════════════════════════════════════════════════╝

Additional context

my firefox and webkit browser won't start. I executed the "mvn exec" command several times:java -dexec.MainClass=com.microsoft.playwright.CLID exec.args="install"", also tried the command from the documentation "mvn exec:java -e -D exec.MainClass=com.microsoft.playwright.CLI -D exec.args="install webkit"" to which I received the error "error:unknown command 'install webkit'". I went to the folder "C:\Users {user}\AppData\Local\ms-playwright\firefox-1454\firefox\firefox.exe " and I didn't find an executable file there firefox.exe . The situation is similar with webkit.

Please fix this moment or tell me what I'm doing wrong. Thank you very much.

Environment

windows 10, Java 21.
mxschmitt commented 4 days ago

Looks similar to https://github.com/microsoft/playwright-java/issues/1542 - I'm unfortunately not proficient with Maven, waiting for Yury to come back. You are mentioning a repository, which one is it?

Maybe similar to https://github.com/mojohaus/exec-maven-plugin/issues/421.

Maxim1-1 commented 4 days ago

Sorry, this repository https://github.com/Maxim1-1/Playwright

mxschmitt commented 3 days ago

I tried to reproduce but was not able to. I used:

PS C:\Users\maxschmitt\Developer\tmp\playwight-repro> java --version
openjdk 21.0.3 2024-04-16 LTS
OpenJDK Runtime Environment Zulu21.34+19-CA (build 21.0.3+9-LTS)
OpenJDK 64-Bit Server VM Zulu21.34+19-CA (build 21.0.3+9-LTS, mixed mode, sharing)
PS C:\Users\maxschmitt\Developer\tmp\playwight-repro> mvn --version
Apache Maven 3.9.8 (36645f6c9b5079805ea5009217e36f2cffd34256)
Maven home: C:\Program Files\apache-maven
Java version: 21.0.3, vendor: Azul Systems, Inc., runtime: C:\Program Files\Zulu\zulu-21
Default locale: en_US, platform encoding: UTF-8
OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows"
PS C:\Users\maxschmitt\Developer\tmp\playwight-repro> 

Which Java and Maven are you using? I'm not a Java expert, but would guess that the Java version/brand (since I'm using Zulu) doesn't make a big difference there, maybe the Maven version.

Maxim1-1 commented 2 days ago

maven version 3.9.2. do all types of browsers work correctly? do you have an executable file firefox.exe or webkit.exe Along the way C:\Users {user}\AppData\Local\ms-playwright\firefox-1454\firefox\firefox.exe or along the way C:\Users {user}\AppData\Local\ms-playwright\firefox-1454\webkit\webkit.exe? Thanks.

Maxim1-1 commented 2 days ago

I switched to version 1.43 and everything worked at first, then I cleaned up the project again, switched to 1.45 and get the same error as before. At first glance, the downloaded files for firefox, chromium, and webkit browsers for different versions of playwright are no different. I can't figure out what's going on. I tried to run it again on version 1.43, then I got this error: [Error: EPERM: operation not permitted, open 'C:\Users{user}\AppData\Local\ms-playwright\firefox-1447\firefox\firefox.exe'] { errno: -4048, code: 'EPERM', syscall: 'open', path: 'C:\Users\{user}\AppData\Local\ms-playwright\firefox-1447\firefox\firefox.exe' } Failed to install browsers Error: Failed to download Firefox 124.0 (playwright build v1447), caused by Error: Download failure, code=1 at ChildProcess. (C:\Users\MAKSGO~1\AppData\Local\Temp\playwright-java-16452516271830092356\package\lib\server\registry\browserFetcher.js:91:16) at ChildProcess.emit (node:events:518:28) at ChildProcess._handle.onexit (node:internal/child_process:294:12) Exception in thread "main" java.lang.RuntimeException: Failed to create driver

Webkit works everywhere, just like chromium.

Maxim1-1 commented 2 days ago

I also deleted the Node js-cache folder (or something like that) and now, when starting the program, regardless of which browser and regardless of the version of playwright, the program tries to install browsers but fails due to an attempt to install firefox. Now it doesn't work for me at all(

Maxim1-1 commented 2 days ago

After a couple of hours of experimenting with finding the cause, a simple restart of the computer helps. If you have problems installing any browser, just restart your computer and restart the program, and playwright will download the desired browser.

mxschmitt commented 1 day ago

So everything is working now? Maybe helpful for others, how did you fix https://github.com/microsoft/playwright-java/issues/1620#issue-2390152730?

Looking at "error:unknown command 'install webkit'".

Maxim1-1 commented 1 day ago

As I understand it, you just need to restart the computer, and then re-launch the playwright, and the desired browser will be downloaded.

mxschmitt commented 18 hours ago

Looks like some transient issue, I'll close it for now. If you have something you can reproduce, feel free to re-file with exact reproduction steps. Thanks!

Maxim1-1 commented 17 hours ago

Good afternoon, yes of course. Thank you very much