Giter Site home page Giter Site logo

[Improvement] "Unresolved attribute reference 'stop' for classes SyncPlaywrightContextManager/ AsyncPlaywrightContextManager appears in IDE about playwright-python HOT 7 CLOSED

microsoft avatar microsoft commented on May 11, 2024
[Improvement] "Unresolved attribute reference 'stop' for classes SyncPlaywrightContextManager/ AsyncPlaywrightContextManager appears in IDE

from playwright-python.

Comments (7)

mxschmitt avatar mxschmitt commented on May 11, 2024

Could you share with us the exact snippet which is causing that error? And which IDE are you using?

from playwright-python.

Igur007 avatar Igur007 commented on May 11, 2024

PyCharm
when to use as:

from playwright import sync_playwright

sync_plw = sync_playwright()
sync_plw.start()

when later is needed to use sync_plw.stop() ---> stop method is not listed by IDE among available methods.

from playwright-python.

mxschmitt avatar mxschmitt commented on May 11, 2024

The usage is a bit different, see this example:

from playwright import sync_playwright

playwright = sync_playwright().start()
for browser_type in [playwright.chromium, playwright.firefox, playwright.webkit]:
    browser = browser_type.launch()
    page = browser.newPage()
    page.goto("http://whatsmyuseragent.org/")
    page.screenshot(path=f"example-{browser_type.name}.png")
    browser.close()

playwright.stop()

from playwright-python.

Igur007 avatar Igur007 commented on May 11, 2024

thanks, I saw it before creation of this improvement ).

from playwright-python.

mxschmitt avatar mxschmitt commented on May 11, 2024

Then I close it okay?

from playwright-python.

Igur007 avatar Igur007 commented on May 11, 2024

of course, you can. My purpose was if I can control an instance of a context manager with the start method, why I need to use __exit__ or not obviously defined "stop". Everything works with or without this change.

from playwright-python.

mxschmitt avatar mxschmitt commented on May 11, 2024

So we internally start a driver which is basically the upstream github.com/microsoft/playwright project under the hood. In the upstream package the magic happens and in the Python world we only call the Node.js methods internally with a custom JSON based protocol over stdin/stdout.
Thats why we have to start and stop it. Stop is probably not that important but start is needed to use it.

from playwright-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.