Skip to content

Commit 67b85e6

Browse files
docs: cherry-pick dotnet docs enhancements + release-notes (#30927)
Co-authored-by: Debbie O'Brien <[email protected]>
1 parent 32bde52 commit 67b85e6

13 files changed

+754
-427
lines changed

docs/src/ci-intro.md

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ jobs:
148148
steps:
149149
- uses: actions/checkout@v4
150150
- name: Setup dotnet
151-
uses: actions/setup-dotnet@v3
151+
uses: actions/setup-dotnet@v4
152152
with:
153153
dotnet-version: 8.0.x
154154
- run: dotnet build
@@ -266,7 +266,7 @@ jobs:
266266
steps:
267267
- uses: actions/checkout@v4
268268
- name: Setup dotnet
269-
uses: actions/setup-dotnet@v3
269+
uses: actions/setup-dotnet@v4
270270
with:
271271
dotnet-version: 8.0.x
272272
- run: dotnet build
@@ -370,7 +370,7 @@ jobs:
370370
steps:
371371
- uses: actions/checkout@v4
372372
- name: Setup dotnet
373-
uses: actions/setup-dotnet@v3
373+
uses: actions/setup-dotnet@v4
374374
with:
375375
dotnet-version: 8.0.x
376376
- run: dotnet build
@@ -388,23 +388,49 @@ jobs:
388388

389389
Once you have your [GitHub actions workflow](#setting-up-github-actions) setup then all you need to do is [Create a repo on GitHub](https://docs.github.com/en/get-started/quickstart/create-a-repo) or push your code to an existing repository. Follow the instructions on GitHub and don't forget to [initialize a git repository](https://github.com/git-guides/git-init) using the `git init` command so you can [add](https://github.com/git-guides/git-add), [commit](https://github.com/git-guides/git-commit) and [push](https://github.com/git-guides/git-push) your code.
390390

391+
######
392+
* langs: js, java, python
393+
391394
<img width="861" alt="Create a Repo and Push to GitHub" src="https://user-images.githubusercontent.com/13063165/183423254-d2735278-a2ab-4d63-bb99-48d8e5e447bc.png"/>
392395

396+
397+
######
398+
* langs: csharp
399+
400+
![dotnet repo on github](https://github.com/microsoft/playwright/assets/13063165/4f1b4cc3-b850-4d60-a99e-24057eaf91ad)
401+
393402
## Opening the Workflows
394403

395404
Click on the **Actions** tab to see the workflows. Here you will see if your tests have passed or failed.
396405

397-
<img width="847" alt="Opening the Workflows" src="https://user-images.githubusercontent.com/13063165/183423584-2ea18038-cd49-4daa-a20c-2205352f0933.png"/>
406+
######
407+
* langs: js, python, java
408+
409+
![opening the workflow](https://user-images.githubusercontent.com/13063165/183423783-58bf2008-514e-4f96-9c12-c9a55703960c.png)
410+
411+
######
412+
* langs: csharp
413+
414+
![opening the workflow](https://github.com/microsoft/playwright/assets/13063165/71793c09-0815-4faa-866b-85684a1f87e5)
398415

399416
On Pull Requests you can also click on the **Details** link in the [PR status check](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/about-status-checks).
400417

401418
<img width="645" alt="pr status checked" src="https://user-images.githubusercontent.com/13063165/183722462-17a985db-0e10-4205-b16c-8aaac36117b9.png" />
402419

420+
403421
## Viewing Test Logs
404422

405423
Clicking on the workflow run will show you the all the actions that GitHub performed and clicking on **Run Playwright tests** will show the error messages, what was expected and what was received as well as the call log.
406424

407-
<img width="839" alt="Viewing Test Logs" src="https://user-images.githubusercontent.com/13063165/183423783-58bf2008-514e-4f96-9c12-c9a55703960c.png"/>
425+
######
426+
* langs: js, python, java
427+
428+
![Viewing Test Logs](https://user-images.githubusercontent.com/13063165/183423783-58bf2008-514e-4f96-9c12-c9a55703960c.png)
429+
430+
######
431+
* langs: csharp
432+
433+
![viewing the test logs](https://github.com/microsoft/playwright/assets/13063165/ba2d8d7b-ffce-42de-95e0-bcb35c421975)
408434

409435

410436
## HTML Report
@@ -441,12 +467,22 @@ Once you have served the report using `npx playwright show-report`, click on the
441467
![playwright trace viewer](https://github.com/microsoft/playwright/assets/13063165/10fe3585-8401-4051-b1c2-b2e92ac4c274)
442468

443469
## Viewing the Trace
444-
* langs: python, java, csharp
470+
* langs: python, java
445471

446472
[trace.playwright.dev](https://trace.playwright.dev) is a statically hosted variant of the Trace Viewer. You can upload trace files using drag and drop.
447473

448474
![playwright trace viewer](https://github.com/microsoft/playwright/assets/13063165/6d5885dc-d511-4c20-b728-040a7ef6cea4)
449475

476+
## Viewing the Trace
477+
* langs: csharp
478+
479+
You can upload Traces which get created on your CI like GitHub Actions as artifacts. This requires [starting and stopping the trace](./trace-viewer-intro#recording-a-trace). We recommend only recording traces for failing tests. Once your traces have been uploaded to CI, they can then be downloaded and opened using [trace.playwright.dev](https://trace.playwright.dev), which is a statically hosted variant of the Trace Viewer. You can upload trace files using drag and drop.
480+
481+
######
482+
* langs: csharp
483+
484+
![playwright trace viewer](https://github.com/microsoft/playwright/assets/13063165/84150084-5019-470a-8449-b61d206bfbb0)
485+
450486
## Publishing report on the web
451487
* langs: js
452488

docs/src/codegen-intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ playwright codegen demo.playwright.dev/todomvc
2929
```
3030

3131
```bash csharp
32-
pwsh bin/Debug/netX/playwright.ps1 codegen demo.playwright.dev/todomvc
32+
pwsh bin/Debug/net8.0/playwright.ps1 codegen demo.playwright.dev/todomvc
3333
```
3434

3535
### Recording a test

docs/src/intro-csharp.md

Lines changed: 31 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ dotnet add package Microsoft.Playwright.MSTest
6969
dotnet build
7070
```
7171

72-
4. Install required browsers by replacing `netX` with the actual output folder name, e.g. `net8.0`:
72+
1. Install required browsers. This example uses `net8.0`, if you are using a different version of .NET you will need to adjust the command and change `net8.0` to your version.
7373

7474
```bash
75-
pwsh bin/Debug/netX/playwright.ps1 install
75+
pwsh bin/Debug/net8.0/playwright.ps1 install
7676
```
7777

78-
If `pwsh` is not available, you have to [install PowerShell](https://docs.microsoft.com/powershell/scripting/install/installing-powershell).
78+
If `pwsh` is not available, you will have to [install PowerShell](https://docs.microsoft.com/powershell/scripting/install/installing-powershell).
7979

8080
## Add Example Tests
8181

@@ -102,28 +102,28 @@ namespace PlaywrightTests;
102102

103103
[Parallelizable(ParallelScope.Self)]
104104
[TestFixture]
105-
public class Tests : PageTest
105+
public class ExampleTest : PageTest
106106
{
107107
[Test]
108-
public async Task HomepageHasPlaywrightInTitleAndGetStartedLinkLinkingtoTheIntroPage()
108+
public async Task HasTitle()
109109
{
110110
await Page.GotoAsync("https://playwright.dev");
111111

112112
// Expect a title "to contain" a substring.
113113
await Expect(Page).ToHaveTitleAsync(new Regex("Playwright"));
114+
}
114115

115-
// create a locator
116-
var getStarted = Page.GetByRole(AriaRole.Link, new() { Name = "Get started" });
117-
118-
// Expect an attribute "to be strictly equal" to the value.
119-
await Expect(getStarted).ToHaveAttributeAsync("href", "/docs/intro");
116+
[Test]
117+
public async Task GetStartedLink()
118+
{
119+
await Page.GotoAsync("https://playwright.dev");
120120

121121
// Click the get started link.
122-
await getStarted.ClickAsync();
122+
await Page.GetByRole(AriaRole.Link, new() { Name = "Get started" }).ClickAsync();
123123

124-
// Expects the URL to contain intro.
125-
await Expect(Page).ToHaveURLAsync(new Regex(".*intro"));
126-
}
124+
// Expects page to have a heading with the name of Installation.
125+
await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Installation" })).ToBeVisibleAsync();
126+
}
127127
}
128128
```
129129

@@ -140,28 +140,28 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
140140
namespace PlaywrightTests;
141141

142142
[TestClass]
143-
public class UnitTest1 : PageTest
143+
public class ExampleTest : PageTest
144144
{
145145
[TestMethod]
146-
public async Task HomepageHasPlaywrightInTitleAndGetStartedLinkLinkingtoTheIntroPage()
146+
public async Task HasTitle()
147147
{
148148
await Page.GotoAsync("https://playwright.dev");
149149

150150
// Expect a title "to contain" a substring.
151151
await Expect(Page).ToHaveTitleAsync(new Regex("Playwright"));
152+
}
152153

153-
// create a locator
154-
var getStarted = Page.GetByRole(AriaRole.Link, new() { Name = "Get started" });
155-
156-
// Expect an attribute "to be strictly equal" to the value.
157-
await Expect(getStarted).ToHaveAttributeAsync("href", "/docs/intro");
154+
[TestMethod]
155+
public async Task GetStartedLink()
156+
{
157+
await Page.GotoAsync("https://playwright.dev");
158158

159159
// Click the get started link.
160-
await getStarted.ClickAsync();
160+
await Page.GetByRole(AriaRole.Link, new() { Name = "Get started" }).ClickAsync();
161161

162-
// Expects the URL to contain intro.
163-
await Expect(Page).ToHaveURLAsync(new Regex(".*intro"));
164-
}
162+
// Expects page to have a heading with the name of Installation.
163+
await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Installation" })).ToBeVisibleAsync();
164+
}
165165
}
166166
```
167167

@@ -170,33 +170,13 @@ public class UnitTest1 : PageTest
170170

171171
## Running the Example Tests
172172

173-
By default tests will be run on Chromium. This can be configured via the `BROWSER` environment variable, or by adjusting the [launch configuration options](./test-runners.md). Tests are run in headless mode meaning no browser will open up when running the tests. Results of the tests and test logs will be shown in the terminal.
174-
175-
<Tabs
176-
groupId="test-runners"
177-
defaultValue="nunit"
178-
values={[
179-
{label: 'NUnit', value: 'nunit'},
180-
{label: 'MSTest', value: 'mstest'}
181-
]
182-
}>
183-
<TabItem value="nunit">
184-
185-
```bash
186-
dotnet test -- NUnit.NumberOfTestWorkers=5
187-
```
188-
189-
</TabItem>
190-
<TabItem value="mstest">
173+
By default tests will be run on Chromium. This can be configured via the `BROWSER` environment variable, or by adjusting the [launch configuration options](./running-tests.md). Tests are run in headless mode meaning no browser will open up when running the tests. Results of the tests and test logs will be shown in the terminal.
191174

192175
```bash
193-
dotnet test -- MSTest.Parallelize.Workers=5
176+
dotnet test
194177
```
195178

196-
</TabItem>
197-
</Tabs>
198-
199-
See our doc on [Test Runners](./test-runners.md) to learn more about running tests in headed mode, running multiple tests, running specific configurations etc.
179+
See our doc on [Running and Debugging Tests](./running-tests.md) to learn more about running tests in headed mode, running multiple tests, running specific configurations etc.
200180

201181
## System requirements
202182

@@ -209,7 +189,7 @@ See our doc on [Test Runners](./test-runners.md) to learn more about running tes
209189

210190
- [Write tests using web first assertions, page fixtures and locators](./writing-tests.md)
211191
- [Run single test, multiple tests, headed mode](./running-tests.md)
212-
- [Learn more about the NUnit and MSTest base classes](./test-runners.md)
213-
- [Generate tests with Codegen](./codegen.md)
192+
- [Generate tests with Codegen](./codegen-intro.md)
214193
- [See a trace of your tests](./trace-viewer-intro.md)
215-
- [Using Playwright as library](./library.md)
194+
- [Run tests on CI](./ci-intro.md)
195+
- [Learn more about the NUnit and MSTest base classes](./test-runners.md)

docs/src/release-notes-csharp.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,82 @@ title: "Release notes"
44
toc_max_heading_level: 2
55
---
66

7+
## Version 1.44
8+
9+
### New APIs
10+
11+
**Accessibility assertions**
12+
13+
- [`method: LocatorAssertions.toHaveAccessibleName`] checks if the element has the specified accessible name:
14+
```csharp
15+
var locator = Page.GetByRole(AriaRole.Button);
16+
await Expect(locator).ToHaveAccessibleNameAsync("Submit");
17+
```
18+
19+
- [`method: LocatorAssertions.toHaveAccessibleDescription`] checks if the element has the specified accessible description:
20+
```csharp
21+
var locator = Page.GetByRole(AriaRole.Button);
22+
await Expect(locator).ToHaveAccessibleDescriptionAsync("Upload a photo");
23+
```
24+
25+
- [`method: LocatorAssertions.toHaveRole`] checks if the element has the specified ARIA role:
26+
```csharp
27+
var locator = Page.GetByTestId("save-button");
28+
await Expect(locator).ToHaveRoleAsync(AriaRole.Button);
29+
```
30+
31+
**Locator handler**
32+
33+
- After executing the handler added with [`method: Page.addLocatorHandler`], Playwright will now wait until the overlay that triggered the handler is not visible anymore. You can opt-out of this behavior with the new `NoWaitAfter` option.
34+
- You can use new `Times` option in [`method: Page.addLocatorHandler`] to specify maximum number of times the handler should be run.
35+
- The handler in [`method: Page.addLocatorHandler`] now accepts the locator as argument.
36+
- New [`method: Page.removeLocatorHandler`] method for removing previously added locator handlers.
37+
38+
```csharp
39+
var locator = Page.GetByText("This interstitial covers the button");
40+
await Page.AddLocatorHandlerAsync(locator, async (overlay) =>
41+
{
42+
await overlay.Locator("#close").ClickAsync();
43+
}, new() { Times = 3, NoWaitAfter = true });
44+
// Run your tests that can be interrupted by the overlay.
45+
// ...
46+
await Page.RemoveLocatorHandlerAsync(locator);
47+
```
48+
49+
**Miscellaneous options**
50+
51+
- New method [`method: FormData.append`] allows to specify repeating fields with the same name in [`Multipart`](./api/class-apirequestcontext#api-request-context-fetch-option-multipart) option in `APIRequestContext.FetchAsync()`:
52+
- ```
53+
```csharp
54+
var formData = Context.APIRequest.CreateFormData();
55+
formData.Append("file", new FilePayload()
56+
{
57+
Name = "f1.js",
58+
MimeType = "text/javascript",
59+
Buffer = System.Text.Encoding.UTF8.GetBytes("var x = 2024;")
60+
});
61+
formData.Append("file", new FilePayload()
62+
{
63+
Name = "f2.txt",
64+
MimeType = "text/plain",
65+
Buffer = System.Text.Encoding.UTF8.GetBytes("hello")
66+
});
67+
var response = await Context.APIRequest.PostAsync("https://example.com/uploadFiles", new() { Multipart = formData });
68+
```
69+
70+
- [`method: PageAssertions.toHaveURL`] now supports `IgnoreCase` [option](./api/class-pageassertions#page-assertions-to-have-url-option-ignore-case).
71+
72+
### Browser Versions
73+
74+
* Chromium 125.0.6422.14
75+
* Mozilla Firefox 125.0.1
76+
* WebKit 17.4
77+
78+
This version was also tested against the following stable channels:
79+
80+
* Google Chrome 124
81+
* Microsoft Edge 124
82+
783
## Version 1.43
884

985
### New APIs

0 commit comments

Comments
 (0)