I have a web application that talks to a connected device from Chrome and which for specific reasons needs to be tested from within a Docker container. The device has two USB endpoints, one of which is an emulated serial device.
The various settings necessary for direct HW and UI access from inside a container are there, whereby I mean that if I launch Chromium manually from inside the official Playwright Docker image, I can use said webapp to flash the device and then connect to it over its TTY connection. In both cases, Chromium first pops up a dialog that I have to interact with (by selecting the device from a list) to grant the browser access to the relevant hardware.
However, if I run a Playwright test that attempts to automate the process, the second dialog does not list any TTY devices at all, causing the test to fail. The test is very simple and only simulates clicks on the webapp’s buttons, which is why I don’t believe the test itself has anything to do with this behavior.
I suspect there is some difference between how I am launching Chromium and how Playwright is doing it, but I haven’t been able to find a way to compare the two. When running Chrome manually, I have to include the --no-sandbox
command-line option. However, I have checked on chrome://sandbox
and Playwright appears to be using this setting as well, probably among others.
Is there any way to see what command-line options Playwright is using to launch Chromium?
2
Answers
It turns out I was approaching the problem from the wrong direction.
On Linux it is fairly easy to get the command-line used to launch any running process:
Find the chrome process with the lowest PID and bam, that's it.
It turns out it's
Yes, you can use the Playwright API to retrieve the command-line arguments used by Playwright to launch Chromium. The browserType.launch() method in Playwright returns a Browser instance, which has a process() method that provides information about the browser process, including the command-line arguments.
Here’s an example of how you can retrieve the command-line options used by Playwright to launch Chromium:
When you run this code, it will launch Chromium using Playwright, retrieve the command-line arguments used for launching, and print them for compare.
Hope this helps.