csf-dev / CSF.Screenplay

Implementation of the Screenplay pattern (aka Journey) in .NET
https://csf-dev.github.io/CSF.Screenplay/
MIT License
13 stars 1 forks source link

Deal with the race condition between getting an element and testing its visibility #93

Closed craigfowler closed 7 years ago

craigfowler commented 7 years ago

This is really not just limited to testing visibility but that's where it comes up most frequently. It's particularly prevalent when waiting for a page to reload.

If I perform the following sequence of actions:

  1. Get an element by a selector
  2. Test the visibility of that element

If between those steps, the page were to reload, the second step would now raise an exception. This would be because the element no longer exists.

craigfowler commented 7 years ago

I think the solution might be to ignore the 'stale element exception' when performing wait operations. Then, if we get one, ensure that we fetch the element again upon the next try.

There's no way to know if we are on the same web page between those steps (above).

craigfowler commented 7 years ago

This was implemented via a "wait for page to load" task.