Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/playwright-google.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Playwright Google search

on:
pull_request:
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: e2e-playwright
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: e2e-playwright/package-lock.json

- name: Install dependencies
run: npm ci

- name: Install Chromium
run: npx playwright install --with-deps chromium

- name: Run Google search spec
run: npx playwright test tests/google-search.spec.ts

- name: Upload Playwright report
if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: e2e-playwright/playwright-report
if-no-files-found: ignore
3 changes: 3 additions & 0 deletions e2e-playwright/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
test-results/
playwright-report/
76 changes: 76 additions & 0 deletions e2e-playwright/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions e2e-playwright/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "ts-java-selenium-testng-playwright",
"private": true,
"scripts": {
"test": "playwright test"
},
"devDependencies": {
"@playwright/test": "1.62.1"
}
}
26 changes: 26 additions & 0 deletions e2e-playwright/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
testDir: './tests',
timeout: 30_000,
expect: {
timeout: 10_000,
},
fullyParallel: true,
forbidOnly: Boolean(process.env.CI),
retries: process.env.CI ? 2 : 0,
reporter: [['html', { outputFolder: 'playwright-report', open: 'never' }]],
use: {
headless: true,
actionTimeout: 10_000,
navigationTimeout: 30_000,
screenshot: 'only-on-failure',
trace: 'retain-on-failure',
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
});
18 changes: 18 additions & 0 deletions e2e-playwright/tests/google-search.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { expect, test } from '@playwright/test';

test('Google search title contains the query', async ({ page }) => {
await page.goto('https://www.google.co.in/?hl=en');

const consentButton = page
.getByRole('button', { name: /accept all|i agree/i })
.first();
if (await consentButton.isVisible().catch(() => false)) {
await consentButton.click();
}

const searchInput = page.locator('[name="q"]');
await searchInput.fill('abc');
await searchInput.press('Enter');

await expect(page).toHaveTitle(/abc/i);
});
Loading