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.

[Feature] Allow passing environment variables into Playwright.create()

See original GitHub issue

I 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:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dubinskycommented, Jun 7, 2021

Could tell us more about the use case and why setting the variable from the command line is not a viable solution in your case?

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)…

0reactions
dubinskycommented, Jun 10, 2021

Thank you!

Read more comments on GitHub >

github_iconTop 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 >

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