[Feature] Allow passing environment variables into Playwright.create()
See original GitHub issueI am embedding Playwright in my Scala code, and need to control browser downloading in code, so I need to set environment variables (PLAYWRIGHT_BROWSERS_PATH
, PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD
) on the ProcessBuilder
used to run the driver.
Since PipeTransport
and Connection
constructors, Playwright.driverProcess
and Playwright.initSharedSelectors()
are not public, this results - in addition to duplicating the code of the PlaywrightImpl.create()
- in the use of reflection.
It would be cleaner if a flavor of Playwright.create()
was added that takes an environment Map<String, String>
and delegates
to a similar flavor of PlaywrightImpl.create()
, which in turn calls pb.environment().putAll()
on the ProcessBuilder
…
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Execute in multiple environment | Playwright Tutorial - Part 80
Playwright Framework #2 | Execute in multiple environment | Playwright Tutorial - Part 80 ; # playwright global setup function to handle the ......
Read more >Getting Started With Playwright - Dave Farinelli
Playwright's preferred method for handling variables is to use environment variables, so being able to locally define variables in your ...
Read more >How to set environment variables like test ... - Stack Overflow
Below code reads properties file based on env we are passing in defaultOptions object and stores entire properties file data into 'this'.
Read more >Environment variables | Checkly
When creating browser checks, you probably run some code locally, store it in a Git repo or copy and paste it around a...
Read more >Getting started with Playwright E2E testing - DEV Community
Playwright uses a global configuration file to specify common settings for each test. ... module.exports = { globalSetup: require.resolve('./tests ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I am embedding Playwright in the code that will be used (to generate PDFs of web-pages) as a part of s service running in the cloud in one scenario and also as a part of a Gradle plugin in another. I would like to be able to configure Playwright dynamically (in code) depending on the deployment context, and I would really like not to have to expose Playwright-specific environment variables at the top level of my Docker container (and its likes) or force the user of my Gradle plugin to be aware of them and have to set them. With Playwright used as an embedded implementation library, forcing the knowledge of such low-level variables on the user is a breach of encapsulation that I’d rather avoid.
Could you tell me what are the reasons for your apparent reluctance to make Playwright less difficult to embed? Using environment variables to control behavior wouldn’t be my first-choice approach, but I think it is reasonable to expect to be able to at least set them from code, without the need to bubble them up all the way to the main entry point of the embedding code (or - worse -to the user thereof)…
Thank you!