Enter, Control+a), load states (domcontentloaded, networkidle),
timeouts in milliseconds, set_default_timeout, expect and TimeoutError
carry over.
Differences
evaluate runs in an isolated world
evaluate runs in an isolated world
Playwright’s The same goes for
evaluate runs in the page’s main world. Here it runs in an
isolated world: the same DOM, but not the page’s own JavaScript globals,
and invisible to the page. DOM work is unaffected. To read a page global such
as window.myApp, pass world="main":locator.evaluate, evaluate_all and wait_for_function.evaluate takes one argument
evaluate takes one argument
arg is passed as the function’s single argument, as in Playwright:
page.evaluate("([a, b]) => a + b", [1, 2]). A thrown error raises
EvaluationError.One browser, one context
One browser, one context
A session is one Chrome with one profile.
browser.contexts has one entry,
browser.new_context() returns it, and page.context is it. Open tabs with
browser.new_page().Input is real operating-system input
Input is real operating-system input
Actions bring their tab to the front first, because only the visible tab
receives input.
keyboard.down() and keyboard.up() aren’t available; use
keyboard.press() with a chord such as Shift+Tab.Strict mode fails fast
Strict mode fails fast
As in Playwright, actions and single-element reads fail when a locator
matches several elements. Here the
TimeoutError comes at once, with a
message saying how many matched.Timeouts have a ceiling
Timeouts have a ceiling
page.set_default_timeout() and page.set_default_navigation_timeout()
work as in Playwright. Without them, locator calls default to 5,000 ms and
navigation to 30,000 ms. A locator call waits at most 60,000 ms, so a
longer default is cut to that for locators. Navigation waits at most
120,000 ms.Uploads are copied into the session first
Uploads are copied into the session first
set_input_files takes what Playwright takes: a path, a payload
{"name", "mimeType", "buffer"}, or a list of either. [] clears the
input. The browser runs in its own machine, so the driver first copies each
file there, then sets it on the input. Each file can be up to 32 MiB.Dialogs are answered by default
Dialogs are answered by default
With no listener, alert, confirm and prompt are dismissed and beforeunload
is accepted, as in Playwright. A
page.on("dialog") listener holds each
dialog open until it calls dialog.accept() or dialog.dismiss(). The
listener runs at your next call on the page, not the moment the dialog
opens:frame_locator takes CSS
frame_locator takes CSS
page.frame_locator() takes a CSS selector for the <iframe>, such as
"iframe[title='Checkout']". Inside it, every locator works as on a page.
page.frames, page.main_frame and page.frame(name=..., url=...) work
too. aria_snapshot() and get_text() read the main frame only.expect_download returns a finished download
expect_download returns a finished download
The block ends once the download has finished, not when it starts.
download.save_as() and download.path() copy the file from the session’s
machine to yours.Acting on a tab brings it to the front
Acting on a tab brings it to the front
expect_popup() returns the new tab’s Page, as in Playwright. Input is real,
so a tab comes to the front when you act on it, opener or popup.Compatibility
- Page
- Locator
- Context and expect
| Playwright | Halyard |
|---|---|
goto, reload, go_back, go_forward | Supported |
url, title(), content(), set_content | Supported |
wait_for_load_state, wait_for_url, wait_for_selector, wait_for_function, wait_for_timeout | Supported |
evaluate, eval_on_selector, eval_on_selector_all | Supported (isolated world by default) |
locator, every get_by_* | Supported |
click, fill, type, press, check and the other selector shortcuts | Supported |
keyboard, mouse, screenshot (PNG or JPEG), aria_snapshot | Supported |
set_viewport_size, viewport_size, bring_to_front, close | Supported |
set_default_timeout, set_default_navigation_timeout | Supported |
set_input_files | Supported |
on("dialog"), once("dialog"), remove_listener("dialog") | Supported |
expect_event and wait_for_event for "dialog" and "download", expect_download | Supported |
frames, main_frame, frame, frame_locator | Supported (frame_locator takes CSS) |
expect_popup, expect_event("popup") | Supported |
screenshot(full_page=True) | Not yet |
add_init_script, route, pdf, events other than "dialog" | Not yet |