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

How to set timeout in .net[Question] #2291

Open guodeo opened 2 years ago

guodeo commented 2 years ago

On the playwright documentation for node.js, it has documentation, however for the .net application there is no such page... how can I change the default timeout for .net please?

debs-obrien commented 2 years ago

For now I can see this for timeout in .NET documentation. https://playwright.dev/dotnet/docs/next/api/class-browsercontext#browser-context-set-default-timeout although there are no example code blocks for it

@mxschmitt is there anything we can do to improve this

mxschmitt commented 2 years ago

Which timeout do you mean? In Playwright for .NET there are multiple timeouts:

a) the test-runner timeout, depends then on your test-harness, e.g. nunit/mstest etc. b) the timeout of your individual actions, you can pass it manually inside each API call as an option or you call context.SetDefaultTimeout c) the Expect timeout, this is 10 seconds by default, we have a tracking issue to make it configurable: https://github.com/microsoft/playwright-dotnet/issues/2237

guodeo commented 2 years ago

Thanks Max b) and c) are what I was after. I was a bit confused because there was a dedicated documentation page on timeouts for .js but not for .NET

mxschmitt commented 2 years ago

We'll keep this issue open to track the progress for adding this dedicated page!

ShaharM7 commented 1 year ago

@guodeo If we compare it to js, with js there is configuration so the playwright acts a little like a framework and less then a library. My recommendation is to use the appettings.json file to configure the timeout. Of course as a result you have to use Program.cs (And this can be complicated)or Startup.cs (This is my recondition) for example:

image image