Skip to content

Commit

Permalink
add different browsers example
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalets committed Jan 22, 2025
1 parent 4bad960 commit 7862459
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
9 changes: 8 additions & 1 deletion features/homepage.feature
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Feature: Playwright Home Page

Scenario: Check title
@chrome
Scenario: scenario for chromium
Given I am on Playwright home page
When I click link "Get started"
Then I see in title "Installation"

@WebKit
Scenario: scenario for webkit
Given I am on Playwright home page
When I click link "Get started"
Then I see in title "Installation"
11 changes: 9 additions & 2 deletions features/steps/fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { test as base, createBdd } from 'playwright-bdd';

type Fixtures = {
// set types of your fixtures
filterBrowsers: void;
};

export const test = base.extend<Fixtures>({
// add your fixtures
filterBrowsers: [
async ({ $tags, defaultBrowserType }, use, testInfo) => {
if (defaultBrowserType === 'chromium' && !$tags.includes('@chrome')) testInfo.skip();
if (defaultBrowserType === 'webkit' && !$tags.includes('@WebKit')) testInfo.skip();
await use();
},
{ auto: true },
],
});

export const { Given, When, Then } = createBdd(test);
7 changes: 5 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ export default defineConfig({
reporter: [
cucumberReporter('html', {
outputFile: 'cucumber-report/index.html',
externalAttachments: true,
attachmentsBaseURL: 'http://127.0.0.1:8080/data',
}),
['html', { open: 'never' }],
['list'],
],
use: {
screenshot: 'on',
Expand All @@ -25,5 +24,9 @@ export default defineConfig({
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
],
});

0 comments on commit 7862459

Please sign in to comment.