xvrh / puppeteer-dart

A Dart library to automate the Chrome browser over the DevTools Protocol. This is a port of the Puppeteer API
BSD 3-Clause "New" or "Revised" License
236 stars 59 forks source link

Unsupported operation: Platform._environment when running on web #304

Open kantino789 opened 7 months ago

kantino789 commented 7 months ago

I am trying to use this library, and I start with the line var browser = await puppeteer.launch();. It works well on Windows, but there is a problem when I run my app as a web app. I get the following error: Error: Unsupported operation: Platform._environment. And this StackTrace:

dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 297:3       throw_
dart-sdk/lib/_internal/js_dev_runtime/patch/io_patch.dart 279:5                   _environment
dart-sdk/lib/io/platform_impl.dart 83:17                                          get environment
dart-sdk/lib/io/platform.dart 177:59                                              get environment
packages/puppeteer/src/puppeteer.dart 299:71                                      defaultArgs
packages/puppeteer/src/puppeteer.dart 135:28                                      launch
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54                runBody

It comes from line 299 in file Puppeteer.dart: noSandboxFlag ??= Platform.environment['CHROME_FORCE_NO_SANDBOX'] == 'true';

My config is the following:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.19.5, on Microsoft Windows [Version 10.0.19045.4291], locale en-GB)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.5.1)
[√] Android Studio (version 2021.2)
[√] IntelliJ IDEA Community Edition (version 2022.1)
[√] VS Code (version 1.88.1)
[√] Connected device (3 available)
[√] Network resources

• No issues found!

Do I do something wrong or is it something that has to be fixed ?