Skip to content

Commit 2edff3b

Browse files
authored
Add retry to CachedElementTests (#79)
1 parent 78afbe2 commit 2edff3b

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Aquality.Selenium.Core.Elements;
22
using Aquality.Selenium.Core.Elements.Interfaces;
33
using Aquality.Selenium.Core.Tests.Applications.WindowsApp.Elements;
4+
using Aquality.Selenium.Core.Utilities;
45
using Aquality.Selenium.Core.Waitings;
56
using Microsoft.Extensions.DependencyInjection;
67
using NUnit.Framework;
@@ -137,14 +138,23 @@ public void Should_ReturnCorrectState_True_WhenWindowIsReopened([ValueSource(nam
137138
private void AssertStateConditionAfterReopen(Func<IElementStateProvider, bool> stateCondition, bool expectedValue)
138139
{
139140
Label testElement = null;
140-
ConditionalWait.WaitForTrue(() =>
141+
AqualityServices.ServiceProvider.GetRequiredService<IActionRetrier>().DoWithRetry(() =>
141142
{
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.");
143+
if (AqualityServices.IsApplicationStarted)
144+
{
145+
AqualityServices.Application.Quit();
146+
}
147+
ConditionalWait.WaitForTrue(() =>
148+
{
149+
OpenDynamicContent();
150+
testElement = new Label(ContentLoc, "Example", ElementState.ExistsInAnyState);
151+
testElement.State.WaitForClickable();
152+
StartLoading();
153+
return testElement.Cache.IsStale;
154+
}, message: "Element should be stale after page is closed.");
155+
},
156+
new[] { typeof(TimeoutException) });
157+
148158
Assume.That(testElement, Is.Not.Null);
149159
OpenDynamicContent();
150160
Assert.AreEqual(expectedValue, stateCondition(testElement.State),

0 commit comments

Comments
 (0)