Skip to content

Commit de2cc61

Browse files
authored
Merge pull request #4107 from Juemuren/part5-zh-update
Update part5: Chinese translation and correction of English materials
2 parents 66d3788 + 8f66193 commit de2cc61

File tree

5 files changed

+2330
-826
lines changed

5 files changed

+2330
-826
lines changed

src/content/5/en/part5d.md

Lines changed: 14 additions & 11 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_:
@@ -521,7 +523,7 @@ describe('Note app', () => {
521523
await page.getByRole('button', { name: 'save' }).click()
522524
await expect(page.getByText('a note created by playwright')).toBeVisible()
523525
})
524-
})
526+
})
525527
})
526528
```
527529

@@ -676,7 +678,7 @@ describe('Note app', () => {
676678
})
677679

678680
// ...
679-
)}
681+
})
680682
```
681683

682684
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.
@@ -700,7 +702,7 @@ const Notification = ({ message }) => {
700702
We could refine the test to ensure that the error message is printed exactly in the right place, i.e. in the element containing the CSS class <i>error</i>:
701703

702704
```js
703-
test('login fails with wrong password', async ({ page }) => {
705+
test('login fails with wrong password', async ({ page }) => {
704706
// ...
705707

706708
const errorDiv = page.locator('.error') // highlight-line
@@ -713,13 +715,13 @@ So the test uses the [page.locator](https://playwright.dev/docs/api/class-page#p
713715
It is possible to test the application's CSS styles with matcher [toHaveCSS](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-have-css). We can, for example, make sure that the color of the error message is red, and that there is a border around it:
714716

715717
```js
716-
test('login fails with wrong password', async ({ page }) => {
718+
test('login fails with wrong password', async ({ page }) => {
717719
// ...
718720

719-
const errorDiv = page.locator('.error')
720-
await expect(errorDiv).toContainText('wrong credentials')
721-
await expect(errorDiv).toHaveCSS('border-style', 'solid') // highlight-line
722-
await expect(errorDiv).toHaveCSS('color', 'rgb(255, 0, 0)') // highlight-line
721+
const errorDiv = page.locator('.error')
722+
await expect(errorDiv).toContainText('wrong credentials')
723+
await expect(errorDiv).toHaveCSS('border-style', 'solid') // highlight-line
724+
await expect(errorDiv).toHaveCSS('color', 'rgb(255, 0, 0)') // highlight-line
723725
})
724726
```
725727

@@ -757,7 +759,7 @@ describe(() => {
757759
// this test is skipped...
758760
test('user can login with correct credentials', async ({ page }) => {
759761
// ...
760-
}
762+
})
761763

762764
// ...
763765
})
@@ -853,7 +855,8 @@ describe('Note app', () => {
853855
await loginWith(page, 'mluukkai', 'salainen') // highlight-line
854856
})
855857

856-
// ...
858+
// ...
859+
})
857860
})
858861
```
859862

@@ -1126,7 +1129,7 @@ By default, debug steps through the test command by command. If it is a complex
11261129
describe('Note app', () => {
11271130
beforeEach(async ({ page, request }) => {
11281131
// ...
1129-
}
1132+
})
11301133

11311134
describe('when logged in', () => {
11321135
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)