Skip to content

Commit 78afbe2

Browse files
authored
Stabilize failing CachedElementTests (#78)
* Stabilize failing tests
1 parent b7d429a commit 78afbe2

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Aquality.Selenium.Core/tests/Aquality.Selenium.Core.Tests/Applications/Browser/CachedElementTests.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,16 @@ public void Should_ReturnCorrectState_True_WhenWindowIsReopened([ValueSource(nam
136136

137137
private void AssertStateConditionAfterReopen(Func<IElementStateProvider, bool> stateCondition, bool expectedValue)
138138
{
139-
OpenDynamicContent();
140-
var testElement = new Label(ContentLoc, "Example", ElementState.ExistsInAnyState);
141-
testElement.State.WaitForClickable();
142-
AqualityServices.Application.Quit();
143-
StartLoading();
144-
ConditionalWait.WaitForTrue(() => testElement.Cache.IsStale, message: "Element should be stale after page is closed.");
139+
Label testElement = null;
140+
ConditionalWait.WaitForTrue(() =>
141+
{
142+
OpenDynamicContent();
143+
testElement = new Label(ContentLoc, "Example", ElementState.ExistsInAnyState);
144+
testElement.State.WaitForClickable();
145+
StartLoading();
146+
return testElement.Cache.IsStale;
147+
}, message: "Element should be stale after page is closed.");
148+
Assume.That(testElement, Is.Not.Null);
145149
OpenDynamicContent();
146150
Assert.AreEqual(expectedValue, stateCondition(testElement.State),
147151
"Element state condition is not expected after reopening the window");

0 commit comments

Comments
 (0)