playwright-dotnet
playwright-dotnet copied to clipboard
[Feature] Expose Ability to Set Expect Timeout
With 1.25, we have the ability to set the default timeout for web-first assertions (Expect) via the runsettings file but only if your testing project is using the Microsoft.Playwright.NUnit package. You can see in WorkerAwareTest where the timeout is getting set in the SetUp method:
[SetUp]
public void WorkerSetup()
{
if (!_allWorkers.TryPop(out _currentWorker))
{
_currentWorker = new();
}
WorkerIndex = _currentWorker.WorkerIndex;
if (PlaywrightSettingsProvider.ExpectTimeout.HasValue)
{
AssertionsBase.SetDefaultTimeout(PlaywrightSettingsProvider.ExpectTimeout.Value);
}
}
The call to AssertionsBase.SetDefaultTimeout seems to set the default timeout. I've been wanting to set a default timeout for Expect assertions since they first came to Playwright.NET but unfortunately, our testing project doesn't use Microsoft.Playwright.NUnit and it appears that AssertionsBase is an internal class so there is no way we can set the timeout.
It would be great if this functionality was exposed in some way so that those of use not using Microsoft.Playwright.NUnit can set a default.