Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to the "@qavajs/steps-playwright" will be documented in this

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [0.29.0]
- :rocket: added _I save screenshot of {string} as {string}_ step

## [0.28.0]
- :rocket: added _I expect every element in {string} collection {playwrightConditionWait}_ step

Expand Down
52 changes: 26 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@qavajs/steps-playwright",
"version": "0.28.0",
"version": "0.29.0",
"description": "steps to interact with playwright",
"main": "./index.js",
"scripts": {
Expand Down Expand Up @@ -41,8 +41,8 @@
"vitest": "^0.33.0"
},
"dependencies": {
"@playwright/test": "^1.36.1",
"@playwright/test": "^1.36.2",
"@qavajs/validation": "^0.6.0",
"playwright": "^1.36.1"
"playwright": "^1.36.2"
}
}
12 changes: 12 additions & 0 deletions src/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,18 @@ When('I save screenshot as {string}', async function(key: string) {
memory.setValue(key, screenshot);
});

/**
* Save element screenshot into memory
* @param {string} alias - element to get screenshot
* @param {string} key - key to store value
* @example I save screenshot of 'Header > Logo' as 'screenshot'
*/
When('I save screenshot of {string} as {string}', async function(alias: string, key: string) {
const element = await getElement(alias);
const screenshot = await element.screenshot();
memory.setValue(key, screenshot);
});

/**
* Save css property of element to memory
* @param {string} property - property to store
Expand Down
8 changes: 8 additions & 0 deletions test-e2e/features/memory.feature
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,11 @@ Feature: memory
When I save 'font-size' css property of '#1 of Simple Text List Items' as 'fontSize'
Then I expect '$color' memory value to be equal 'rgb(95, 158, 160)'
Then I expect '$fontSize' memory value to be equal '20px'

Scenario: page screenshot
When I save screenshot as 'pageScreenshot'
Then I expect '$pageScreenshot[0]' memory value to be equal '$js(137)'

Scenario: element screenshot
When I save screenshot of 'Simple Text Input' as 'elementScreenshot'
Then I expect '$elementScreenshot[0]' memory value to be equal '$js(137)'
7 changes: 7 additions & 0 deletions test-e2e/step-definitions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@ Then('I expect {string} memory value to contain {string}', async function(actual
const expectedValue = memory.getValue(expected);
expect(actualValue).to.contain(expectedValue);
});

Then('I expect {string} memory value to have type {string}', async function(actual, expected) {
const actualValue = memory.getValue(actual);
const expectedValue = memory.getValue(expected);
expect(actualValue).to.be.a(expectedValue);
});