Skip to content

Commit e914b1d

Browse files
committed
reduce flakeyness of idrag browser automation
1 parent 24f4266 commit e914b1d

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

src/playwright-boostrap/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ npm install
1515
IDRAC_USERNAME=root IDRAC_PASSWORD=calvin npx playwright test scripts/iDRAC-set-virtual-terminal-html5.spec.ts --debug
1616
```
1717

18+
To run without `--debug` but with headed mode, use `--headed`
19+
20+
e.g:
21+
```
22+
IDRAC_USERNAME=root IDRAC_PASSWORD=calvin npx playwright test scripts/iDRAC-set-virtual-terminal-html5.spec.ts --headed
23+
```
24+
25+
1826
# Test generation / writing new scripts/tests
1927

2028
```
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
export default defineConfig({
4+
timeout: 5 * 60 * 1000,
5+
// expect timeout is different from test timeout ( https://playwright.dev/docs/test-timeouts#expect-timeout )
6+
expect: {
7+
timeout: 120 * 1000,
8+
},
9+
// Look for test files in the "tests" directory, relative to this configuration file.
10+
testDir: 'scripts',
11+
12+
// Run all tests in parallel.
13+
fullyParallel: true,
14+
15+
// Fail the build on CI if you accidentally left test.only in the source code.
16+
forbidOnly: !!process.env.CI,
17+
18+
// Retry on CI only.
19+
retries: process.env.CI ? 2 : 0,
20+
21+
// Opt out of parallel tests on CI.
22+
workers: process.env.CI ? 1 : undefined,
23+
24+
// Reporter to use
25+
reporter: 'html',
26+
27+
use: {
28+
// Base URL to use in actions like `await page.goto('/')`.
29+
baseURL: 'http://127.0.0.1:3000',
30+
31+
// Collect trace when retrying the failed test.
32+
trace: 'on-first-retry',
33+
},
34+
// Configure projects for major browsers.
35+
projects: [
36+
{
37+
name: 'chromium',
38+
use: { ...devices['Desktop Chrome'] },
39+
},
40+
],
41+
});

src/playwright-boostrap/scripts/iDRAC-set-virtual-terminal-html5.spec.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ test.use({
66

77
let IDRAC_PASSWORD = process.env["IDRAC_PASSWORD"]; // Default: root
88
let IDRAC_USERNAME = process.env["IDRAC_USERNAME"]; // Default: calvin
9+
let IDRAC_HOST = process.env["IDRAC_HOST"]; // E.g. https://192.168.0.120/
910

1011
test('test', async ({ page }) => {
11-
await page.goto('https://192.168.0.120/start.html');
12-
await page.goto('https://192.168.0.120/login.html');
12+
test.setTimeout(120000);
13+
// Note: The IDRAC redirects visits to '/start.html' to
14+
// 'login.html' by default.
15+
await page.goto(IDRAC_HOST + '/start.html');
16+
await expect(page.getByText('Enterprise')).toBeVisible();
17+
await expect(page.locator('#user')).toBeVisible();
1318
await page.locator('#user').click();
1419
await page.locator('#user').press('Tab');
1520
await page.locator('#user').dblclick();
@@ -20,6 +25,7 @@ test('test', async ({ page }) => {
2025
await page.getByRole('link', { name: 'Submit' }).click();
2126
await page.locator('#keeppassword').check();
2227
await page.getByRole('link', { name: 'Continue' }).click();
28+
await expect(page.frameLocator('frame[name="globalnav"]').getByText('Logout')).toBeVisible();
2329

2430

2531
await page.frameLocator('frame[name="da"]').frameLocator('iframe[name="help"]').getByRole('link', { name: 'Settings' }).click();

0 commit comments

Comments
 (0)