Playwright Need To Know » History » Version 1
rainerkoenig, 2023-06-02 13:33
1 | 1 | rainerkoenig | # Playwright Need To Know |
---|---|---|---|
2 | |||
3 | ## Installation inside VS code |
||
4 | - Install the Microsoft playwright extension |
||
5 | - **Open an empty folder** (otherwise it will write where you are) |
||
6 | - Ctlr-shift-p "install playwright" |
||
7 | - Don't select "Install Linux dependencies" (this will invoke `apt-get? that you don't have on openSUSE) |
||
8 | |||
9 | ## Modify the default language in VS code for Playwright |
||
10 | |||
11 | When playing around with Playwright inside VS code I noticed that recording a test (running `playwright codegen`) used German for some Labels on the login page. |
||
12 | |||
13 | The recorded file looked like this: |
||
14 | |||
15 | ~~~ |
||
16 | await page.getByLabel('Benutzername').click(); |
||
17 | await page.getByLabel('Benutzername').fill('root'); |
||
18 | await page.getByLabel('Passwort').click(); |
||
19 | await page.getByLabel('Passwort').fill('linux'); |
||
20 | await page.getByRole('button', { name: 'Anmelden' }).click(); |
||
21 | ~~~ |
||
22 | The problem is that *running* the test does this in English. So we will fail because in the english settings "Benutzername" should translate to "User name". |
||
23 | |||
24 | To avoid this mess you need to define a default language for Playwright inside VS code. Open the settings.json and add: |
||
25 | |||
26 | ~~~ |
||
27 | "playwright.env": { |
||
28 | "LANG": "en-EN", |
||
29 | } |
||
30 | ~~~ |
||
31 | |||
32 | With those settings the test recording will happen in English and you don't need to translate the locators by hand. |