You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That is, "chromium" actually points to the JSModule itself, and calling chromium.launch() calls the module-level Launch() wrapper, which internally creates a Chromium BrowserType and calls BrowserType.Launch().
Which means this is possible:
import{chromium}from'k6/x/browser';exportdefaultfunction(){// logs v0.4.0, the xk6-browser version, not the Chromium versionconsole.log(chromium.version);// logs the device configuration map, which should be browser-agnosticconsole.log(chromium.devices);}
Suggested solution
As mentioned here and here, import { chromium } from 'k6/x/browser'; should actually import the Chromium BrowserType instance directly, so the script can call all of its public methods. This would allow us to easily support other BrowserType implementations in the future.
And if the user wants access to module-level attributes, the script should import the module instead, e.g. import k6b from 'k6/x/browser;.
The text was updated successfully, but these errors were encountered:
In #462 we made a
chromium
object importable in scripts, but the way it's done is a bit convoluted:xk6-browser/main.go
Lines 61 to 68 in aadaffe
That is,
"chromium"
actually points to theJSModule
itself, and callingchromium.launch()
calls the module-levelLaunch()
wrapper, which internally creates a ChromiumBrowserType
and callsBrowserType.Launch()
.Which means this is possible:
Suggested solution
As mentioned here and here,
import { chromium } from 'k6/x/browser';
should actually import the ChromiumBrowserType
instance directly, so the script can call all of its public methods. This would allow us to easily support otherBrowserType
implementations in the future.And if the user wants access to module-level attributes, the script should import the module instead, e.g.
import k6b from 'k6/x/browser;
.The text was updated successfully, but these errors were encountered: