First, install the necessary dependencies. You'll need the @playwright/test
test runner. Install it with npm:
npm install -D @playwright/test
Next, create a configuration file in your project directory, like playwright.config.ts
. This file will define your test configurations.
In this file, import the necessary modules from @playwright/test
:
import { defineConfig, devices } from '@playwright/test';
Then, define your test configurations using the defineConfig
function. You can specify different projects for different browsers or devices.
To run tests on a tablet device, use one of the predefined device options from the devices
module:
{
name: 'Tablet',
use: devices['iPad landscape'],
}
This configures your project to run tests on an iPad in landscape mode.
Now, you can run your tests with the specified configuration using the Playwright test runner CLI. Navigate to your project directory in your terminal or command prompt.
To execute all configured projects including tablets, run:
npx playwright test
To execute only specific projects or configurations, provide their names as arguments:
npx playwright test --project Tablet
Playwright will then run the tests with the specified configuration on a tablet device. You can view the test results in the console output.
Remember to customize your configuration file according to your specific needs and desired tablet device configurations. For more detailed instructions and examples, refer to Playwright's official documentation.
If you still have questions, please ask a question and I will try to answer it.
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].