Skip to content

Commit 8071f1c

Browse files
committed
Update part5: Chinese translation and correction of English materials
- Translated the new English materials in Part 5 into Chinese - corrected the trailing brackets and indentation of some codes in the English materials
1 parent 0579db2 commit 8071f1c

File tree

5 files changed

+2333
-829
lines changed

5 files changed

+2333
-829
lines changed

src/content/5/en/part5d.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ or remove the entry for any problematic browsers from your _playwright.config.js
8484
// name: 'webkit',
8585
// use: { ...devices['Desktop Safari'] },
8686
//},
87+
// ...
88+
]
8789
```
8890

8991
Let's define an npm script for running tests and test reports in _package.json_:
@@ -538,7 +540,7 @@ describe('Note app', () => {
538540
await page.getByRole('button', { name: 'save' }).click()
539541
await expect(page.getByText('a note created by playwright')).toBeVisible()
540542
})
541-
})
543+
})
542544
})
543545
```
544546

@@ -693,7 +695,7 @@ describe('Note app', () => {
693695
})
694696

695697
// ...
696-
)}
698+
})
697699
```
698700

699701
The test verifies with the method [page.getByText](https://playwright.dev/docs/api/class-page#page-get-by-text) that the application prints an error message.
@@ -718,11 +720,11 @@ We could refine the test to ensure that the error message is printed exactly in
718720

719721
```js
720722
test('login fails with wrong password', async ({ page }) => {
721-
// ...
723+
// ...
722724

723-
const errorDiv = page.locator('.error') // highlight-line
724-
await expect(errorDiv).toContainText('wrong credentials')
725-
})
725+
const errorDiv = page.locator('.error') // highlight-line
726+
await expect(errorDiv).toContainText('wrong credentials')
727+
})
726728
```
727729

728730
So the test uses the [page.locator](https://playwright.dev/docs/api/class-page#page-locator) method to find the component containing the CSS class <i>error</i> and stores it in a variable. The correctness of the text associated with the component can be verified with the expectation [toContainText](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-contain-text). Note that the [CSS class selector](https://developer.mozilla.org/en-US/docs/Web/CSS/Class_selectors) starts with a dot, so the <i>error</i> class selector is <i> .error</i>.
@@ -731,13 +733,13 @@ It is possible to test the application's CSS styles with matcher [toHaveCSS](htt
731733

732734
```js
733735
test('login fails with wrong password', async ({ page }) => {
734-
// ...
736+
// ...
735737

736738
const errorDiv = page.locator('.error')
737739
await expect(errorDiv).toContainText('wrong credentials')
738740
await expect(errorDiv).toHaveCSS('border-style', 'solid') // highlight-line
739741
await expect(errorDiv).toHaveCSS('color', 'rgb(255, 0, 0)') // highlight-line
740-
})
742+
})
741743
```
742744

743745
Colors must be defined to Playwright as [rgb](https://rgbcolorcode.com/color/red) codes.
@@ -774,7 +776,7 @@ describe(() => {
774776
// this test is skipped...
775777
test('user can login with correct credentials', async ({ page }) => {
776778
// ...
777-
}
779+
})
778780

779781
// ...
780782
})
@@ -860,11 +862,12 @@ describe('Note app', () => {
860862
await loginWith(page, 'mluukkai', 'salainen') // highlight-line
861863
})
862864

863-
test('a new note can be created', () => {
865+
test('a new note can be created', () => {
866+
// ...
867+
})
868+
864869
// ...
865870
})
866-
867-
// ...
868871
})
869872
```
870873

@@ -977,7 +980,7 @@ module.exports = defineConfig({
977980
baseURL: 'http://localhost:5173',
978981
},
979982
// ...
980-
}
983+
})
981984
```
982985

983986
All the commands in the tests that use the application url, e.g.
@@ -1133,7 +1136,7 @@ By default, debug steps through the test command by command. If it is a complex
11331136
describe('Note app', () => {
11341137
beforeEach(async ({ page, request }) => {
11351138
// ...
1136-
}
1139+
})
11371140

11381141
describe('when logged in', () => {
11391142
beforeEach(async ({ page }) => {

src/content/5/zh/part5.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ lang: zh
1414
- <i>Brought alongside Cypress as an alternative for Playwright End to end testing</i> -->
1515
<i>2024年3月3日部分更新</i>
1616
- <i>Jest被Vitests取代</i>
17-
- <i>与Cypress一起,作为Playwright端到端测试的替代方案</i>
17+
- <i>将Cypress与Playwright并列,作为一个端到端测试的替代方案</i>
1818

1919
</div>

0 commit comments

Comments
 (0)