Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
docs(dotnet): add docs for SetDefaultExpectTimeout (#29259)
Max Schmitt0f8d61901218
diff --git a/docs/src/intro-csharp.md b/docs/src/intro-csharp.mdindex 9281f886c9..43126bb63e 100644--- a/docs/src/intro-csharp.md+++ b/docs/src/intro-csharp.md@@ -91,7 +91,7 @@ Edit the `UnitTest1.cs` file with the code below to create an example end-to-end}><TabItem value="nunit">-```csharp+```csharp title="UnitTest1.cs"using System.Text.RegularExpressions;using System.Threading.Tasks;using Microsoft.Playwright;@@ -130,7 +130,7 @@ public class Tests : PageTest</TabItem><TabItem value="mstest">-```csharp+```csharp title="UnitTest1.cs"using System.Text.RegularExpressions;using System.Threading.Tasks;using Microsoft.Playwright;diff --git a/docs/src/library-csharp.md b/docs/src/library-csharp.mdindex ff68f86fd9..5dab997f7e 100644--- a/docs/src/library-csharp.md+++ b/docs/src/library-csharp.md@@ -66,6 +66,9 @@ You can do the following to leverage Playwright's web-first assertions when youusing Microsoft.Playwright;using static Microsoft.Playwright.Assertions;+// Change the default 5 seconds timeout if you'd like.+SetDefaultExpectTimeout(10_000);+using var playwright = await Playwright.CreateAsync();await using var browser = await playwright.Chromium.LaunchAsync();var page = await browser.NewPageAsync();diff --git a/docs/src/test-assertions-csharp-java-python.md b/docs/src/test-assertions-csharp-java-python.mdindex 0fa60874b0..1926aaad26 100644--- a/docs/src/test-assertions-csharp-java-python.md+++ b/docs/src/test-assertions-csharp-java-python.md@@ -56,11 +56,12 @@ tests/test_foobar.py:22: AssertionError```## Setting a custom timeout-* langs: python+* langs: python, csharpYou can specify a custom timeout for assertions either globally or per assertion. The default timeout is 5 seconds.### Global timeout+* langs: python```python title="conftest.py"from playwright.sync_api import expect@@ -68,6 +69,64 @@ from playwright.sync_api import expectexpect.set_options(timeout=10_000)```+### Global timeout+* langs: csharp++<Tabs+ groupId="test-runners"+ defaultValue="nunit"+ values={[+ {label: 'NUnit', value: 'nunit'},+ {label: 'MSTest', value: 'mstest'}+ ]+}>+<TabItem value="nunit">++```csharp title="UnitTest1.cs"+using Microsoft.Playwright;+using Microsoft.Playwright.NUnit;+using NUnit.Framework;++namespace PlaywrightTests;++[Parallelizable(ParallelScope.Self)]+[TestFixture]+public class Tests : PageTest+{+ [OneTimeSetUp]+ public void GlobalSetup()+ {+ SetDefaultExpectTimeout(10_000);+ }+ // ...+}+```++</TabItem>+<TabItem value="mstest">++```csharp title="UnitTest1.cs"+using Microsoft.Playwright;+using Microsoft.Playwright.MSTest;+using Microsoft.VisualStudio.TestTools.UnitTesting;++namespace PlaywrightTests;++[TestClass]+public class UnitTest1 : PageTest+{+ [ClassInitialize]+ public static void GlobalSetup(TestContext context)+ {+ SetDefaultExpectTimeout(10_000);+ }+ // ...+}+```++</TabItem>+</Tabs>+### Per assertion timeout```python title="test_foobar.py"@@ -76,3 +135,7 @@ from playwright.sync_api import expectdef test_foobar(page: Page) -> None:expect(page.get_by_text("Name")).to_be_visible(timeout=10_000)```++```csharp title="UnitTest1.cs"+await Expect(Page.GetByText("Name")).ToBeVisibleAsync(new() { Timeout = 10_000 });+```diff --git a/docs/src/writing-tests-csharp.md b/docs/src/writing-tests-csharp.mdindex 1aea228c68..938b24429f 100644--- a/docs/src/writing-tests-csharp.md+++ b/docs/src/writing-tests-csharp.md@@ -19,7 +19,7 @@ Take a look at the example test below to see how to write a test using using [lo}><TabItem value="nunit">-```csharp+```csharp title="UnitTest1.cs"using System.Text.RegularExpressions;using System.Threading.Tasks;using Microsoft.Playwright;@@ -60,7 +60,7 @@ public class Tests : PageTest</TabItem><TabItem value="mstest">-```csharp+```csharp title="UnitTest1.cs"using System.Text.RegularExpressions;using System.Threading.Tasks;using Microsoft.Playwright;@@ -132,7 +132,7 @@ The Playwright NUnit and MSTest test framework base classes will isolate each te}><TabItem value="nunit">-```csharp+```csharp title="UnitTest1.cs"using System.Threading.Tasks;using Microsoft.Playwright.NUnit;using NUnit.Framework;@@ -154,7 +154,7 @@ public class Tests : PageTest</TabItem><TabItem value="mstest">-```csharp+```csharp title="UnitTest1.cs"using System.Threading.Tasks;using Microsoft.Playwright.MSTest;using Microsoft.VisualStudio.TestTools.UnitTesting;@@ -189,7 +189,7 @@ You can use `SetUp`/`TearDown` in NUnit or `TestInitialize`/`TestCleanup` in MST}><TabItem value="nunit">-```csharp+```csharp title="UnitTest1.cs"using System.Threading.Tasks;using Microsoft.Playwright.NUnit;using NUnit.Framework;@@ -218,7 +218,7 @@ public class Tests : PageTest</TabItem><TabItem value="mstest">-```csharp+```csharp title="UnitTest1.cs"using System.Threading.Tasks;using Microsoft.Playwright.MSTest;using Microsoft.VisualStudio.TestTools.UnitTesting;