← Quiz: Page Object Model: all 10 questions
Quiz: Page Object Model · Question 4 of 10
Why store By locators instead of WebElement fields?
Why store By locators instead of WebElement fields?
- A.By objects are faster to type
- B.Elements are found fresh each time, avoiding StaleElementReferenceException
- C.WebElement can't be stored in a field
- D.By works in all browsers but WebElement doesn't
Answer & explanation
Correct answer: Elements are found fresh each time, avoiding StaleElementReferenceException
A stored WebElement can go stale after the page re-renders.
Can you get the rest right without peeking?
Take the timed Quiz: Page Object Model quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →