grafana / xk6-browser

The browser module adds support for browser automation and end-to-end web testing via the Chrome Devtools Protocol to k6.
https://grafana.com/docs/k6/latest/javascript-api/k6-browser/
GNU Affero General Public License v3.0
344 stars 41 forks source link

Refactor `parseBrowserContextOptions` to Sobek #1526

Closed inancgumus closed 3 weeks ago

inancgumus commented 3 weeks ago

What?

Refactor parseBrowserContextOptions to use direct Sobek transformation.

Why?

After the refactorings we made in #1270, it's now possible to let Sobek perform this transformation alone.

Checklist

Script

I also used the script to test it using my old friend Printf in Browser.NewContext etc..

export default async function() {
  const context = await browser.newContext({
    acceptDownloads: true,
    downloadsPath: "/tmp",
    bypassCSP: true,
    colorScheme: "dark",
    deviceScaleFactor: 1,
    extraHTTPHeaders: {
        "X-Header": "value",
    },
    geolocation: { latitude: 51.509865, longitude: -0.118092 },
    hasTouch: true,
    httpCredentials: { username: "admin", password: "password" },
    ignoreHTTPSErrors: true,
    isMobile: true,
    javaScriptEnabled: true,
    locale: "fr-FR",
    offline: true,
    permissions: ["camera", "microphone"],
    reducedMotion: true,
    screen: { width: 800, height: 600 },
    timezoneID: "Europe/Paris",
    userAgent: "my agent",
    viewport: { width: 800, height: 600 },
  });
}

Related PR(s)/Issue(s)