question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] No Playwright class typed definition anymore in @next

See original GitHub issue

Context:

  • Playwright Version: 0.11.1-next.1584947279674 (March 23, 2020)
  • Operating System: Linux

Code Snippet

import { Playwright } from 'playwright-core/lib/server/playwright'

const pw = new Playwright({
  browsers: ['webkit', 'chromium', 'firefox'],
});

Describe the bug

In version 0.11.1 and some of the recent next releases it was working. Now the types are missing.

Version 0.11.1 example: https://unpkg.com/playwright-core@0.11.1/lib/server/playwright.d.ts

I think it’s related to #1166.

cc @JoelEinbinder

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
JoelEinbindercommented, Mar 23, 2020

https://github.com/mxschmitt/try-playwright/blob/6b112eec4b2fdd2e831b9bf7d3052ecf6119bb55/backend/src/playwright.ts#L86-L101

Hmm, yep its a kinda hacky approach to overwrite the methods.

The main issue here is that you want multiple playwright objects in the same node process, with their own prototype hacks on it. If you are ok with the same hacks everywhere, then requiring playwright-core directly will work. I don’t think this will ever work cleanly though.

Edit: Another use case is on Try Playwright for that the usage in the Monaco editor. there I also just have used the previous class Playwright as a playwright interface.

Instead try typeof import('playwright-core').

Also I found a issue in playwright-video: https://github.com/qawolf/playwright-video/blob/9a7912f6fb04aa86ff5c4be757ef5dccfddd0dcb/src/ScreencastFrameCollector.ts#L4 that the type could not be resolved.

This just needs to use the CDPSession type from the root of playwright instead.

Closing this issue for now as I consider it not a bug. Feel free to keep up the discussion here about internal types, or file new issues for specific things that might be missing/broken.

1reaction
JoelEinbindercommented, Mar 23, 2020

Is it possible for playwright-core to expose the types for power users so we don’t have to manually define our own declaration files?

I really don’t want to support people hacking on our internal code. I’d much rather support your use cases in the public api.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to wait for JavaScript to finish in playwright - Stack Overflow
First I fill the text and then click on tab key to invoke the JavaScript that formats the value in the element. await...
Read more >
What You Need to Know About E2E Testing with Playwright
Playwright is a testing and automation framework that enables E2E ... Next, we included the 'page-objects/pages' (diverse classes) for ...
Read more >
playwright._impl._api_types.error: execution context was ...
I came into this issue today, and found that this problem occurs in this case: I was use page object loading a url...
Read more >
Let's play with playwright using F# scripts. - Marcin Golenia Blog
Playwright's puppeteer-like SDKs promise automatic wait and support for Python/.Net/Node.js/Java. Let's try this stuff in F#!
Read more >
Using Playwright Test to run Unit Tests - of Patrick Kerschbaum
This means the test subject is executed directly; this differs from the "usual" way of using Playwright to open a browser, navigate to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found