Skip to content

An E2E Leg Hung Waiting for Two Identical Frames

Adityo Guni Waluyo

An E2E leg that hangs with no error can be waiting for a stability condition the page can never satisfy. The fix is a synchronous scroll.

TL;DR

A capture run stalled silently because scrollIntoViewIfNeeded waits for element stability that lazy-loading lists can never satisfy. Switching to synchronous Element.scrollIntoView plus per-leg log markers fixed the hang and made stalls locatable. The takeaway: check what a leg waits on before raising timeouts, and name every leg.

The capture run reached the second leg and stopped moving. No error, no failed assertion, no timeout message. The process was still alive and the browser still open, but the log's last line was a leg start with no matching end. The run sat like that for 15 to 23 minutes before it was killed by hand. Each leg records a 67 to 106 second mp4 that has to be watchable end to end, so a leg that never finishes is not a slow leg. It is a broken one.

The first guess was the familiar one: a heavy lazy-loading listing page simply needed more patience. The response was to raise the timeouts and add a retry on that leg. Neither changed anything. The suite already ran with an unlimited action timeout, so there was no wait left to raise, and the retry stalled on the same leg at the same spot.

Slowness resolves eventually. This never did.

What the auto-wait contract promises

Read the contract of the primitive doing the scrolling. locator.scrollIntoViewIfNeeded() runs two actionability checks before it scrolls: Visible, and Stable [7]. Stable has a precise definition in the same documentation: the element must hold the same bounding box for at least two consecutive animation frames [7].

The target in this run was a card inside a lazy-loading listing. Rows mount as the card nears the viewport, container heights change, and the card's bounding box keeps moving. Two identical consecutive frames never arrive while the DOM keeps mutating. The check is not waiting for the page to settle. It is waiting for a condition the page cannot satisfy, which is why raising any timeout value changes nothing.

That makes sense once the assumption behind the primitive is spelled out. Auto-waiting scroll helpers assume a page that eventually stops re-laying out, which covers most forms and buttons and fails on any list that loads content in response to the scroll it is waiting for. The transferable case is wider than one listing: any auto-waiting scroll against a container that never stabilizes waits forever, and the symptom is always the same silent stall.

A synchronous scroll and a named leg

If the only goal is to bring an element into view before a click or a screenshot, the DOM already has a synchronous primitive for it. Element.scrollIntoView() scrolls the element's ancestor containers so the element is visible to the user [8], in one pass, with nothing to wait for. The fix wraps that call in the page context:

await row.evaluate((el) => el.scrollIntoView({ block: "center" }));

With the scroll synchronous, the timeboxes went back to a normal 300 second budget.

The run also gained per-leg log markers, a plain [leg] line on start and on completion. This is the part worth copying into any suite with a silent hang: name every leg. The next stall then reads as [leg] detail-capture start with no matching done line, and the hang has a location instead of a mystery. Pacing between actions was raised to 2.5 to 3 second pauses so each recorded mp4 stays watchable. To verify the fix, run with the markers on and confirm every start line has a matching done line inside the 300 second budget. If a done line is still missing, the stall moved into that leg, and the same read-the-contract step applies to whatever the leg waits on next.

Content over visibility as proof

The same run carried evidence for the display modes. In noimage mode, the target row was verified by reading page content instead of checking visibility. The row can sit inside a hidden inactive tab, so a visibility check reports absence for a row that is actually present in the DOM. In video mode, the proof sat at the request level: the detail URL issues a 301 redirect into the /videos tree.

The rule the suite now follows is cheap to keep: any scroll before a capture is a plain DOM call, and auto-wait is reserved for elements that are expected to settle. When a leg hangs with no error and no timeout firing, look at what the leg waits on before touching any timeout value. If that target sits in a container that keeps re-laying out, no timeout will end the wait.

Related articles