https://github.com/mondata-dev/wdio-viewport-size
A port of setViewportSize to webdriverio 5
https://github.com/mondata-dev/wdio-viewport-size
Last synced: 11 months ago
JSON representation
A port of setViewportSize to webdriverio 5
- Host: GitHub
- URL: https://github.com/mondata-dev/wdio-viewport-size
- Owner: mondata-dev
- Created: 2020-03-20T18:09:27.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-31T12:05:08.000Z (about 2 years ago)
- Last Synced: 2025-08-09T18:56:36.864Z (11 months ago)
- Language: TypeScript
- Size: 325 KB
- Stars: 4
- Watchers: 0
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WebdriverIO Viewport Size
This is a port of the old [`setViewportSize` function](https://github.com/webdriverio-boneyard/v4/blob/master/lib/commands/setViewportSize.js) of webdriverio v4 to webdriverio v5.
It allows setting the size of the viewport which is helpful for consistent visual regression testing.
## Usage
1. Install the package:
```bash
npm install --save-dev wdio-viewport-size
```
2. Import the service and add it to your `wdio.conf.js` file:
```javascript
const { ViewportSizeService } = require("wdio-viewport-size");
exports.config = {
// other configuration
services: [[ViewportSizeService]],
};
```
3. Use available commands:
```typescript
browser.getViewport(): Promise<{ width: number, height: number }>
browser.setViewport(width: number, height: number, retries = 5): Promise
```
## Example
The following repo contains a boilerplate setup for e2e testing with webdriverio: https://github.com/mondata-dev/e2e.
It includes `wdio-viewport-size` and uses it to set the viewport size before each feature to the same value.