1

I need to assign specific browsers and devices to multiple tests. How to indicate this in the test?

  1. Chromium Android, Pixel 5 device
  2. WebKit Desktop for Mac

And won't there be a conflict with the fact that I already have settings in the configuration file, but they are much wider than what is needed for these tests?

import { test, expect, Page } from '@playwright/test';

import { regisClientChatWeb } from '../baseStep/registration/regisClientChat';
import { stepToPaymentSelectHideAnswer } from '../baseStep/pay/paySettingsUserChat';
import { billingMobTenkoffPageUserChat } from '../baseStep/pay/billingUserChat';

test('Mob Simple answer with a guarantee of an answer for payment', async ({ page }) => {
    await regisClientChatWeb(page);
const selectGarantConsultation = page.locator('text=***');
    await selectGarantConsultation.waitFor();
    await page.locator('text=****').click();
    await stepToPaymentSelectHideAnswer(page);
    await billingMobTenkoffPageUserChat(page);
const leadCart = page.locator('text=***');
    await leadCart.waitFor();
    await page.locator('text=****').click();
    await page.screenshot({ path: Date.now() + 'newAnswer1.png', fullPage: true});
    // await expect(page).toHaveScreenshot();

});

Thank you for your help

Ken White
  • 123,280
  • 14
  • 225
  • 444
  • If you specify multiple browsers and devices in your config as multiple projects, then the whole test suite will run multiple times with the different settings. – Max Schmitt Sep 11 '22 at 08:59
  • Thanks for the answer. Currently in the config file I have 3 mobile browsers, 3 web browsers. If I run a test that is only written for mobile browsers, I get 6 tests (three of them are using web browsers that I don't need). I want to write in the test file that this test should only run on three mobile browsers, regardless of what is specified in the config file. – Ivan Okunkov Sep 16 '22 at 10:44

1 Answers1

0

If I’m understanding correctly from your question and comment, you just need certain tests to only run for a subset of 3 mobile browsers out of the 6 total you configured.

If that’s accurate, I actually just listed some different ways to conditionally skip tests in an answer to another similar question, so linked that for more details. You mentioned you were looking for a skip within a file approach, so here’s a possible solution for a whole file or describe block:

test.skip(({ isMobile }) => !isMobile);

Or you could always skip within a single test/beforeEach.

Hope that helps!

David R
  • 493
  • 2
  • 8