Files
rewards-farmer/tests
Ethan Stoner e17053bd48 keep the rewards tab when a task fails, and put it back on the rewards page
The cleanup after each task called close_all_other_tabs() with no arguments.
That defaults `exceptions` to the currently focused handle, so when a task died
with a Bing tab in focus the cleanup kept the Bing tab and closed the Rewards
one. Every later task then looked for Rewards controls on a search results page
and reported [SKIP] for a UI that was present and working the whole time. One
failure cost the rest of the run.

Measured in the container rather than reasoned about: with a Rewards tab and a
Bing tab open and the Bing one focused, close_all_other_tabs() leaves
['https://www.bing.com/search?q=weather'] behind and the Rewards handle is gone.

Two separate things have to hold before the next task can work, and they failed
independently. The right tab has to survive, so restore_main_tab names the
handle recorded at startup instead of trusting whatever happens to be focused.
The surviving tab also has to be showing the right page, which the tab fix alone
does not give you: run_search_batch navigates the main tab to bing.com itself,
so a failure part way through that batch strands the main tab on a search page
with no second tab involved at all.

Navigating only happens when the step did not finish, and is skipped when the
browser is already on the Rewards host, so a clean run navigates nowhere and a
panel that merely failed to render does not cost a page load.

Both recoveries swallow their own errors. Raising here would replace the real
failure with the tidy-up's, which is why the close_all_other_tabs call was
wrapped in the first place.

End to end in a real browser: two tabs with the Bing one focused become one tab,
the original handle, on rewards.bing.com/about (the logged out redirect), and a
main tab stranded on bing.com recovers too. Fifteen unit tests cover the tab
choice, the missing-main-tab fallback, the failure and skip paths, a clean run
navigating nowhere, and a driver too broken to do either.

Refs #63

Claude-Session: https://claude.ai/code/session_0113hp36oUBeMqG7twfuC8rE
2026-09-09 08:25:38 -07:00
..