Skip to content

Commit 8c5c3b1

Browse files
committed
Go back to setting test id only when supression happens but try to clean it after each test.
1 parent 92cad9a commit 8c5c3b1

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Components/test/E2ETest/Infrastructure/ServerTestBase.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,30 @@ public void Navigate(string relativeUrl)
3131
Browser.Navigate(_serverFixture.RootUri, relativeUrl);
3232
}
3333

34+
public override async Task DisposeAsync()
35+
{
36+
TryCleanupTestId();
37+
38+
await base.DisposeAsync();
39+
}
40+
3441
protected override void InitializeAsyncCore()
3542
{
3643
// Clear logs - we check these during tests in some cases.
3744
// Make sure each test starts clean.
3845
((IJavaScriptExecutor)Browser).ExecuteScript("console.clear()");
3946
}
47+
48+
private void TryCleanupTestId()
49+
{
50+
try
51+
{
52+
((IJavaScriptExecutor)Browser).ExecuteScript($"sessionStorage.removeItem('test-id')");
53+
}
54+
catch (Exception ex)
55+
{
56+
// exception here most probably means session storage is not available - no cleanup needed
57+
Output?.WriteLine("Error when removing test id from session storage: " + ex.Message);
58+
}
59+
}
4060
}

src/Shared/E2ETesting/BrowserTestBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public IWebDriver Browser
4949

5050
public BrowserFixture BrowserFixture { get; }
5151

52-
public Task DisposeAsync()
52+
public virtual Task DisposeAsync()
5353
{
5454
return Task.CompletedTask;
5555
}

0 commit comments

Comments
 (0)