microsoft / playwright-dotnet

.NET version of the Playwright testing and automation library.
https://playwright.dev/dotnet/
MIT License
2.47k stars 235 forks source link

[Feature] Set Default global LocatorAssertions in .NET. #2603

Closed MWRAUTO closed 8 months ago

MWRAUTO commented 1 year ago

Hello! as we spoke in this issue: https://github.com/microsoft/playwright/issues/23471

I would like to request for a posibility to set expect global timeout while we're setting up browser context, same as we have default timeout & default navigation timeout in screenshot below.

image

image

Materix commented 1 year ago

As workaround I use:

        typeof(Playwright).Assembly.GetType("Microsoft.Playwright.Core.AssertionsBase")!
            .GetMethod("SetDefaultTimeout", BindingFlags.Static | BindingFlags.NonPublic)!
            .Invoke(null, new object[] { _defaultTimeout });

in any static ctor which are always loaded

SephVin commented 1 year ago

Thanks for workaround! I really don't understand why we can't set default timeout for Assertions. Something like Assertions.SetDefaultTimeout(...). Not everyone can use the .runsettings

FR https://github.com/microsoft/playwright-dotnet/issues/2259 also about this

S-Kulyk commented 11 months ago

Totally on the same page. Unless the workaround above is applied, Playwright makes pretty much obliges users to use runsettings file while configuration from code/custom config sources might be preferable to someone

mxschmitt commented 8 months ago

Folding into #2259