Skip to content

Commit 30855f9

Browse files
Match value wait (#41)
added to match value wait
1 parent aecb929 commit 30855f9

File tree

6 files changed

+51
-12
lines changed

6 files changed

+51
-12
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ All notable changes to the "@qavajs/steps-playwright" will be documented in this
44

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

7+
## [0.0.19]
8+
- :rocket: added to match value wait
9+
710
## [0.0.18]
811
- :rocket: added interceptor steps
912
- :rocket: added support of multiple events for taking screenshots

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": "0.0.18",
3+
"version": "0.0.19",
44
"description": "steps to interact with playwright",
55
"main": "./index.js",
66
"scripts": {

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ defineParameterType({
99

1010
defineParameterType({
1111
name: 'playwrightValueWait',
12-
regexp: /((not )?to (?:be )?(equal|contain|above|below))/,
12+
regexp: /((not )?to (?:be )?(equal|contain|above|below|match))/,
1313
transformer: p => p,
1414
useForSnippets: false
1515
});

src/valueWait.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,19 @@ function toSimpleEqual(this: any, actual: any, expected: any) {
2727

2828
expect.extend({ toSimpleEqual });
2929

30+
function regexp(regexpLike: string | RegExp) {
31+
if (typeof regexpLike === 'string') {
32+
return new RegExp(regexpLike, 'gmi')
33+
}
34+
return regexpLike
35+
}
36+
3037
export const valueValidations = {
3138
EQUAL: 'equal',
3239
CONTAIN: 'contain',
3340
ABOVE: 'above',
34-
BELOW: 'below'
41+
BELOW: 'below',
42+
MATCH: 'match'
3543
}
3644

3745
const notClause = '(not )?';
@@ -45,7 +53,8 @@ const waits = {
4553
[valueValidations.EQUAL]: async (poll: any, expected: any) => poll.toSimpleEqual(expected),
4654
[valueValidations.CONTAIN]: async (poll: any, expected: any) => poll.toContain(expected),
4755
[valueValidations.ABOVE]: async (poll: any, expected: any) => poll.toBeGreaterThan(parseInt(expected)),
48-
[valueValidations.BELOW]: async (poll: any, expected: any) => poll.toBeLessThan(parseInt(expected))
56+
[valueValidations.BELOW]: async (poll: any, expected: any) => poll.toBeLessThan(parseInt(expected)),
57+
[valueValidations.MATCH]: async (poll: any, expected: any) => poll.toMatch(regexp(expected))
4958
}
5059

5160
/**

test-e2e/features/waits.feature

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,41 @@ Feature: waits
1313
| Visible Element | to be visible |
1414
| Hidden Element | to be invisible |
1515

16-
Scenario: wait for text
17-
Then I wait until text of 'Loading' to be equal '100%'
16+
Scenario Outline: wait for text (<condition>)
17+
Then I wait until text of 'Loading' <condition> '<expectation>'
1818

19-
Scenario: wait for property
20-
Then I wait until 'value' property of 'Loading Input' to be equal '100%'
19+
Examples:
20+
| condition | expectation |
21+
| to equal | 100% |
22+
| to contain | 10 |
23+
| to match | ^.00%$ |
24+
| not to equal | 10% |
25+
| not to contain | 10 |
26+
| not to match | ^.0%$ |
27+
28+
Scenario Outline: wait for property (<condition>)
29+
Then I wait until 'value' property of 'Loading Input' <condition> '<expectation>'
30+
31+
Examples:
32+
| condition | expectation |
33+
| to equal | 100% |
34+
| to contain | 10 |
35+
| to match | ^.00%$ |
36+
| not to equal | 10% |
37+
| not to contain | 10 |
38+
| not to match | ^.0%$ |
39+
40+
Scenario Outline: wait for attribute (<condition>)
41+
Then I wait until 'style' attribute of 'Hidden Element' <condition> '<expectation>'
2142

22-
Scenario: wait for attribute
23-
Then I wait until 'style' attribute of 'Hidden Element' to contain 'hidden'
43+
Examples:
44+
| condition | expectation |
45+
| to equal | visibility: hidden; |
46+
| to contain | hidden |
47+
| to match | hidden;$ |
48+
| not to equal | visibility: displayed; |
49+
| not to contain | displayed |
50+
| not to match | displayed;$ |
2451

2552
Scenario Outline: wait for number of elements in collection
2653
Then I wait until number of elements in 'Wait Collection' collection <condition> '<expected>'

0 commit comments

Comments
 (0)