Selenium / Scenario
The Cache That Went Stale: PageFactory Forensics
A React re-render kills a @CacheLookup field, and a @FindBys that was meant to be an OR quietly matches nothing. Two annotation traps, one page object.
- Difficulty
- Hard
- Format
- Scenario
- Points
- 200
- Estimate
- 13 min
// MISSION BRIEF
Your Mission
CartPage worked for a year. Then the frontend moved to React, and now badgeCount() throws StaleElementReferenceException, but only after the badge UPDATES. Meanwhile a locator that was supposed to match two kinds of buy buttons returns an empty list.
You have the page object, the stack trace, and the team's observations. Explain what the PageFactory proxy really does, what @CacheLookup changes, and what @FindBys was never designed to mean.
// FIRST CONTACT
Battle teaser
First artifact
CartPage.java
Why does badgeCount() throw only after the badge updates?
- AReact apps do not support PageFactory at all
- BInteger.parseInt cannot handle values above 1
- C@CacheLookup froze the WebElement located on first use; React REPLACES the badge node on re-render, so the cached reference points at a detached element, stale by definition
- DThe CSS selector became invalid when the count changed
Answers, scoring, hints, and the full battle stay sealed.
// SKILL TAGS
seleniumjavapagefactorystale-element