Skip to content

Commit 1c40d86

Browse files
added I expect {value} css property of every element in {playwrightLocator} collection {validation} {value} step (#144)
1 parent 27fac4c commit 1c40d86

File tree

5 files changed

+37
-3
lines changed

5 files changed

+37
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
1414

1515
:microscope: - experimental
1616

17+
## [2.3.0]
18+
- :rocket: added `I expect {value} css property of every element in {playwrightLocator} collection {validation} {value}` step
19+
1720
## [2.2.1]
1821
- :rocket: added capability to pass page object as instance
1922

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@qavajs/steps-playwright",
3-
"version": "2.2.1",
3+
"version": "2.3.0",
44
"description": "steps to interact with playwright",
55
"main": "./index.js",
66
"scripts": {

src/validations.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,34 @@ Then(
252252
}
253253
);
254254

255+
/**
256+
* Verify that css property of every element in collection satisfies condition
257+
* @param {string} property - property to verify
258+
* @param {string} alias - collection to verify
259+
* @param {string} validationType - validation
260+
* @param {string} value - expected value
261+
* @example I expect 'color' css property of every element in 'Table > Rows' collection to be equal 'rgb(42, 42, 42)'
262+
* @example I expect 'font-family' css property of every element in 'Labels' to contain 'Fira'
263+
*/
264+
Then(
265+
'I expect {value} css property of every element in {playwrightLocator} collection {validation} {value}',
266+
async function (property: MemoryValue, collection: Locator, validation: Validation, expected: MemoryValue) {
267+
const propertyName = await property.value();
268+
const expectedValue = await expected.value();
269+
for (let i = 0; i < await collection.count(); i++) {
270+
const locator = collection.nth(i);
271+
const actualValue = () => locator.evaluate(
272+
(node: Element, propertyName: string) => getComputedStyle(node).getPropertyValue(propertyName),
273+
propertyName
274+
);
275+
await validation.poll(actualValue, expectedValue, {
276+
timeout: this.config.browser.timeout.value,
277+
interval: this.config.browser.timeout.valueInterval
278+
});
279+
}
280+
}
281+
);
282+
255283
/**
256284
* Verify that text of an alert meets expectation
257285
* @param {string} validationType - validation

test-e2e/features/validations.feature

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,6 @@ Feature: validations
6464
Examples:
6565
| collection | condition |
6666
| Present Collection | to be present |
67+
@debug
68+
Scenario: collection css property
69+
Then I expect 'background-color' css property of every element in 'Simple Text List Items' collection to be equal 'rgba(0, 0, 0, 0)'

0 commit comments

Comments
 (0)