We have a patch in our code that speeds up coming back to a window. See the code below.
When a spec switches away from a window and later switches back, Chrome's renderer for that window remains in a backgrounded state. CDP input commands (e.g. Input.dispatchMouseEvent) then stall for ~5 seconds while Chrome reactivates the renderer. This affects any spec that uses multiple windows.
Calling page.activate after switching sends Target.activateTarget, which wakes the renderer immediately. This reduces wait time, on some specs more than 10s.
We use the following patch.
module CupriteActivateOnSwitch
# Sends Target.activateTarget after switching, waking Chrome's renderer for the target window.
# @return [true]
def switch_to_window(target_id)
super
@page.activate
end
end
Capybara::Cuprite::Browser.class_eval {prepend CupriteActivateOnSwitch}
We have a patch in our code that speeds up coming back to a window. See the code below.
When a spec switches away from a window and later switches back, Chrome's renderer for that window remains in a backgrounded state. CDP input commands (e.g. Input.dispatchMouseEvent) then stall for ~5 seconds while Chrome reactivates the renderer. This affects any spec that uses multiple windows.
Calling page.activate after switching sends Target.activateTarget, which wakes the renderer immediately. This reduces wait time, on some specs more than 10s.
We use the following patch.