What is a JSHandle?
mainA JSHandle represents an in-page JavaScript object. You can create one using Page#evaluate_handle.
Lifecycle and Memory Management:
JSHandleprevents the referenced JavaScript object from being garbage collected in the browser.- To release the reference manually, use
JSHandle#dispose. JSHandleinstances are automatically disposed when the origin frame navigates or the parent context is destroyed.
JSHandle instances can be passed as arguments to Page#eval_on_selector, Page#evaluate, and Page#evaluate_handle.
window_handle = page.evaluate_handle("window")
# ...
window_handle.dispose