'How to achieve browser resizing in run time using playwright? in a e2e test run

We have in protractor like: browser.driver.manage().window().setSize( width - 30, height );

How to achieve this in playwright?



Solution 1:[1]

To resize your playwrite browser window: you can use the method page.setViewportSize()

For Example:

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

test('test', async ({ page }) => {
  page.setViewportSize({ width: 600, height: 600 });
  // do stuff then resize to a particular device size 
  page.setViewportSize(devices['iPhone X'].viewport);
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Leo103