Page Factory StaleElementReference Exception

0 votes
I'm learning PageFactory and I understood the concept of initElements() from where the elements are located. Now, if I click on an element and if that results in other elements in DOM changing, then it might throw a StaleElementReferenceException. How will we solve this issue?
Do I have to find that element once again by expecting there to be a change in the Element's properties in the DOM? Or is there another way out?
Apr 21, 2018 in Selenium by kappa3010
• 2,090 points
1,459 views

1 answer to this question.

0 votes
Usually, a StaleElementReferenceException is thrown when:
1. The element has been deleted entirely or
2. The element is no longer attached to the DOM

So by clicking on an element, if there is a change in DOM structure, then you have to simply re-initialize ( using initElements() ) all the elements for further use.
answered Apr 21, 2018 by king_kenny
• 3,710 points

Related Questions In Selenium

0 votes
1 answer

How @FindBy annotation of Page Factory can be used in Selenium?

Hey Mridul, Page Factory uses annotation @FindBy to ...READ MORE

answered Jul 4, 2019 in Selenium by Anvi
• 14,150 points
10,315 views
+1 vote
1 answer

Explicit Wait with Page Factory is not working as expected

Hey Tewadros, you can use implicit wait ...READ MORE

answered Oct 14, 2019 in Selenium by Abha
• 28,140 points
2,101 views
0 votes
1 answer
0 votes
1 answer
+1 vote
4 answers

Need to wait until page is completely loaded - Selenium WebDriver

You can try something like -  new WebDriverWait(firefoxDriver, ...READ MORE

answered Dec 21, 2019 in Selenium by Robin
64,303 views
0 votes
2 answers

How to scroll the Page up or down in Selenium WebDriver? (using java)

JavascriptExecutor jsx = (JavascriptExecutor)driver; jsx.executeScript("window.scrollBy(0,555)", ""); or Action classes ...READ MORE

answered Sep 6, 2020 in Selenium by Sri
• 3,190 points
18,925 views
0 votes
1 answer
0 votes
1 answer
0 votes
2 answers

Selenium: Diff between POM (page object model) and page factory?

Hi, In POM (Page Object Model) you create ...READ MORE

answered Mar 14, 2019 in Selenium by Ellen Dares
6,464 views
+1 vote
2 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP