Skip to content

Error: browser.newContext: Error: Unknown scheme for Initializer: Selectors. #43

@phproberto-bluebox

Description

@phproberto-bluebox

I've an authenticated API and with playwright I've a function like this:

    const newBrowserPageFromApi = async ({ browser, api }: { browser: Browser, api: APIRequestContext }): Promise<Page> => {
        const storageState = await api.storageState();
        const apiContext = await browser.newContext({ storageState });
        return await apiContext.newPage();
    };

That creates a new page authenticated using the already authenticated API for browsing purposes and saves me to use the logic to enter the login + password. It works perfectly when used directly in playwright but fails when using it through browserstack. The error is:

1) [chrome-latest:Windows 11-browserstack] › extensions/wow_ecommerce/tests/admin/config/wow_ecommerce_config.spec.ts:18:7 › WowEcommerce Admin > Config > Wow Ecommerce › Config can be saved

    Error: browser.newContext: Error: Unknown scheme for Initializer: Selectors.

       at ../composables/api/useWowApiTools.ts:7

       5 |         const storageState = await api.storageState();
       6 |         console.log('storageState', storageState);
    >  7 |         const apiContext = await browser.newContext({ storageState });
         |                            ^
       8 |         return await apiContext.newPage();
       9 |     };
      10 |

I couldn't find anything in playwright related to this and it works directly in playwright so I think this is specific to the browserstack integration. Information:

platforms:
  - os: Windows
    osVersion: 11
    browserName: chrome
    browserVersion: latest

Activity

phproberto-bluebox

phproberto-bluebox commented on Jun 26, 2025

@phproberto-bluebox
Author

Update: I've found the issue comparing this repository with our setup. The tests were failing with even the most basic test like just loading google. Not related to the fact that I'm inheriting localStorage.

It turns out that you cannot use the latest version of playwright. Tests passing within this repo show this information:

Image

And tests failing in our setup with exactly the same config:

Image

So the only difference was the playwright version. I checked your package-lock.json file and has a forced version:

    "node_modules/@playwright/test": {
      "version": "1.40.1",
      "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.40.1.tgz",
      "integrity": "sha512-EaaawMTOeEItCRvfmkI9v6rBkF1svM8wjl/YPRrg2N2Wmp+4qJYkWtJsbew1szfKKDm6fPLy4YAanBhIlf9dWw==",
      "dev": true,
      "dependencies": {
        "playwright": "1.40.1"
      },
      "bin": {
        "playwright": "cli.js"
      },
      "engines": {
        "node": ">=16"
      }
    },

So even using "@playwright/test": "latest", in your package.json the used version is always 1.40.1. I forced our system to use that version and then the error was gone. So I think you should know that the SDK does not work with current playwright versions.

added a commit that references this issue on Jun 27, 2025
phproberto

phproberto commented on Jun 30, 2025

@phproberto

I've sent a pull request to increase the playwright repo version to v1.52.0 which is the latest one working with the browserstack SDK. Current version (v1.40.0) is from 2023.

#44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @phproberto@phproberto-bluebox

        Issue actions

          Error: browser.newContext: Error: Unknown scheme for Initializer: Selectors. · Issue #43 · browserstack/node-js-playwright-browserstack