Rayrun
← Back to Discord Forum

How to rezognize tablet

Hello, i have this configuration + configurations for mobile and desktop. How can I verify whether test runs with this configuration (on tablet) { name: 'tablet', use: { ...devices['Galaxy Tab S4 landscape'], headless: false, locale: 'cs-CZ', isMobile: true, }, },

This thread is trying to answer question "How can I verify whether a test runs with a specific configuration (on a tablet)?"

2 replies

how do you want to verify it?

Tablet, desktop and mobile have another CSS. I need to know what is my device to work with them. So any option is good for me. No matter whether I verify it by name: 'tablet' or device itself

Answer

Configuring Playwright to Run Tests on a Tablet

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.

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

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 luc@ray.run.