diff --git a/CHANGELOG.md b/CHANGELOG.md index 81d71bc..9affbbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,10 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how :pencil: - chore :microscope: - experimental -## [Unreleased] +## [0.53.0] +- :rocket: added _I grant {string} permission_ step +- :rocket: added _I revoke browser permissions_ step +- :rocket: added _I set {string} geolocation_ step - :beetle: improved _I scroll until_ steps to use same locator ## [0.52.0] diff --git a/package-lock.json b/package-lock.json index f0d268b..3f68591 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@qavajs/steps-playwright", - "version": "0.52.0", + "version": "0.53.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@qavajs/steps-playwright", - "version": "0.52.0", + "version": "0.53.0", "license": "MIT", "dependencies": { "@playwright/test": "^1.47.0", diff --git a/package.json b/package.json index ff80cc8..8afb455 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@qavajs/steps-playwright", - "version": "0.52.0", + "version": "0.53.0", "description": "steps to interact with playwright", "main": "./index.js", "scripts": { diff --git a/src/actions.ts b/src/actions.ts index 0b0e352..045deb5 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -465,3 +465,33 @@ When('I tap {string}', async function (alias: string) { const element = await getElement(alias); await element.tap(); }); + +/** + * Grants specified permission to the browser context. + * @param {string} permissionAlias - permission alias. + * @example I grant 'geolocation' permission + * Permissions documentation can be found here https://playwright.dev/docs/api/class-browsercontext#browser-context-grant-permissions-option-permissions + */ +When('I grant {string} permission', async function (permissionAlias: string) { + const permission = await getValue(permissionAlias); + await context.grantPermissions([permission]); +}); + +/** + * Clears all permission overrides for the browser context. + */ +When('I revoke browser permissions', async function () { + await context.clearPermissions(); +}); + +/** + * Sets a geolocation for a current context. + * @param {string} geolocationAlias - geolocation memory alias. + * @example I set '$minsk' geolocation + * where '$minsk' is memory alias of location object { latitude: 53.53, longitude: 27.34 }; + * Passing null or undefined emulates position unavailable. + */ +When('I set {string} geolocation', async function (geolocationAlias: string) { + const geolocation = await getValue(geolocationAlias); + await context.setGeolocation(geolocation); +}); diff --git a/test-e2e/apps/actions.html b/test-e2e/apps/actions.html index a264ea4..1305d75 100644 --- a/test-e2e/apps/actions.html +++ b/test-e2e/apps/actions.html @@ -76,8 +76,15 @@
- +