I am repeatedly getting a very annoying problem when automating my test cases using Selenium/C# in Visual Studio.
This test is designed around validating search criteria text. In order for me to test each criteria, I have to:
- Navigate to the the app's homepage
- Click on the search app
- On the search page, enter valid criteria
- On the search results page, assert that the search criteria appears in text as what was searched for.
- Repeat steps 1-3 with different search criteria.
- Verify all search criterias on the results page appear as they should.
When I get to step 5 (navigating back to the homepage), I get the following exception: "threw exception: OpenQA.Selenium.StaleElementReferenceException: Element is no longer valid"
I had gotten this before and got around it by adding a "wait.Until(ExpectedConditions.ElementIsVisible" command- not entirely sure why this worked.
However, the above solution is becoming very tedious as it requires me to enter an instance for EACH element that I call to, which will end up being x30 more.
Any help will be greatly appreciated.