Comments (1)
I figured out the solution, it was not a bug. I had to put the event handler before going to the page.
# build the URL of our page
url = f'http://localhost:{local_port}/{app}/{str(object.slug)}'
print(" PAGE URL: ", url)
# append any uncaught javascript errors in browser error logs to list
uncaught_errors = []
page.on("pageerror", lambda exc: uncaught_errors.append(exc))
# append any javascript errors in browser error logs to list
error_logs = []
page.on("console", lambda msg: error_logs.append(msg.text) if msg.type == "error" else None)
# go to page once there are no more than 2 network connections for at least 500 milliseconds
page.goto(url, wait_until="networkidle")
# assert that 'Page Not Found' is not in title tag of DOM
title = page.title()
assert 'Page Not Found' not in title, '\n\n 404 error!'
# assert that no uncaught javascript errors are in browser error logs
assert len(uncaught_errors) == 0, f"The following uncaught JavaScript errors were reported for {url}:\n{uncaught_errors}"
# assert that no javascript errors are in browser error logs
assert len(error_logs) == 0, f"The following JavaScript errors were reported for {url}:\n{error_logs}"
`
from playwright-python.
Related Issues (20)
- [Bug]: Playwright video does not get created after context is closed until all tests are run HOT 1
- [Bug]: Using `sync_playwright` to bypass context manager (e.g. in REPL) HOT 3
- [Bug]: Remove unnecessary 'type-extensions' requirement
- [Feature]: Update Incorrect type-hints HOT 2
- [Bug]: initializing sync API stuck when using uvloop HOT 1
- [Bug]: When the page.route() function is set, it fails to intercept requests, causing them to stall when the document of the page is new. HOT 3
- [Docs]: Update documentation on basic authentication with pytest HOT 1
- [Bug]: BrowserType.connect doesn't work with the Pytest plugin HOT 1
- [Ports]: Backport client side changes
- [Question]:When I use connect_over_cdp and the download request method is POST, expect_download cannot work,This is a common bug
- How to wait a new page loading? HOT 1
- [Question]:When I use connect_over_cdp and the download request method is POST, expect_download cannot work HOT 5
- 👾👾[Bug]: Can not login twitter by the cookies HOT 3
- modify the browser options
- [Docs]: How to modify firefoxPrefs with python / pytest.ini HOT 3
- [Bug]: route_from_har replay failed, chrome warning "net::ERR_FAILED", unable to replay HOT 2
- [Bug]: Playwright Sync API Usage Issue: Error Encountered When Running Multiple Test Files HOT 2
- [Bug]: context_browse.route is broken for requests initiated by service worker HOT 1
- [Bug]: Future exception was never retrieved future: <Future finished exception=TargetClosedError('Target page, context or browser has been closed')> HOT 1
- TimeoutError on locator click
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from playwright-python.