Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question/Feature Request: Extension support #558

Closed
Banou26 opened this issue Jan 22, 2020 · 7 comments
Closed

Question/Feature Request: Extension support #558

Banou26 opened this issue Jan 22, 2020 · 7 comments

Comments

@Banou26
Copy link

Banou26 commented Jan 22, 2020

Could WebExtensions be supported across browsers, or will they be restricted to chrome ?

@Banou26 Banou26 changed the title Feature Request: Extension support Question/Feature Request: Extension support Jan 22, 2020
@JoelEinbinder
Copy link
Contributor

Considering WebKit doesn’t support web extensions, would it be fair to consider this a request for Firefox extension support?

You should be able to load extensions into Firefox though some launch arguments. But we don’t currently have a way for you to evaluate JavaScript in the extension context.

@Banou26
Copy link
Author

Banou26 commented Jan 22, 2020

Yeah, i was mainly thinking about FF

@aslushnikov
Copy link
Collaborator

@Banou26 you can already load web extensions to firefox using web-ext - that's the recommended way to load extensions to ff. We explored it a while back here: puppeteer/puppeteer#4162 (comment)

Same instructions should work for PlayWright; cc'ing @denar90 who poked a lot into this.

Hope this helps!

@gurupras
Copy link

Could you kindly share what the expected sequence is to start a playwright-controlled Firefox instance with extensions installed?

I don't quite understand how to trigger all of this from my playwright script.
Should we be overriding executablePath in browser.launch() to point to web-ext and pass its arguments?

@lfilho
Copy link

lfilho commented Jun 13, 2020

I second what @gurupras said.

I'm also very interested in how to use Playwright for testing WebExtensions. I tried the approach above with Playwright but I'm stuck with the following error when running my script:

Error when running playwright script:

    WebSocket error: Unexpected server response: 400
    =================== firefox.connect logs ===================
    <ws connecting> ws://127.0.0.1:1234/c1f80464-a717-b542-92bf-8884ddef3501/
    <ws connect error> ws://127.0.0.1:1234/c1f80464-a717-b542-92bf-8884ddef3501/ Unexpected server response: 400
    <ws disconnected> ws://127.0.0.1:1234/c1f80464-a717-b542-92bf-8884ddef3501/
    ============================================================

Here's my code relevant bits:

web-ext confirmation juggler is listening:

[firefox/index.js][debug] Firefox stdout: Juggler listening on ws://127.0.0.1:1234/c1f80464-a717-b542-92bf-8884ddef3501

my playwright script:

  browser = await browserWrapper.firefox.connect({
    wsEndpoint: 'ws://127.0.0.1:1234/',
    // also tried with:
    // wsEndpoint: 'ws://127.0.0.1:1234/c1f80464-a717-b542-92bf-8884ddef3501',
    // and:
    // wsEndpoint: 'ws://127.0.0.1:1234/c1f80464-a717-b542-92bf-8884ddef3501/',

    logger: { // doesn't show any other extra information
      isEnabled: () => true,
      log: (name, severity, message, args) => console.log(`${name} ${message}`),
    },
  });

I'm using: "playwright-firefox": "1.1.1"

That's the only missing bit in my quest to fully automate my extension's testing :)
Any ideas how to accomplish testing that? /cc @aslushnikov @denar90

Thank you!

@lfilho
Copy link

lfilho commented Jun 13, 2020

I have also just tried a different approach, without using juggler but rather connecting to the remote debugger as suggested in a different thread. I posted all details here: mozilla/web-ext#1927 (there's details about puppeteer and playwright)

@aslushnikov
Copy link
Collaborator

Could you kindly share what the expected sequence is to start a playwright-controlled Firefox instance with extensions installed?

@gurupras @lfilho Oops sorry it took me a while. I posted some details here: mozilla/web-ext#1927 (comment)

sand4rt pushed a commit to sand4rt/playwright that referenced this issue Dec 21, 2022
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants