I am repeatedly getting a very annoying problem when automating my test cases using /C# in Visual Studio.

This test is designed around validating search criteria text. In order for me to test each criteria, I have to:

  1. Navigate to the the app’s homepage
  2. Click on the search app
  3. On the search page, enter criteria
  4. On the search results page, assert that the search criteria appears in text as what was searched for.
  5. Repeat 1-3 with different search criteria.
  6. 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 :
“threw exception:
OpenQA.Selenium.StaleElementReferenceException: is no 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.



Source link https://sqa.stackexchange.com/questions/34943/selenium-with-c-element-is-no-longer-valid-exception-being--when-repeat

LEAVE A REPLY

Please enter your comment!
Please enter your name here