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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
## [0.0.23]
- :rocket: added types to global members
- :rocket: added _I switch to 'IFrame' frame_
- :rocket: added _I switch to 'window name or title' window_

## [0.0.22]
- :beetle: fixed exports of mock and poDefine
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"homepage": "https://github.com/qavajs/steps-playwright#readme",
"devDependencies": {
"@cucumber/cucumber": "^9.1.2",
"@qavajs/cli": "^0.0.22",
"@qavajs/cli": "^0.0.23",
"@qavajs/console-formatter": "^0.2.1",
"@qavajs/memory": "^1.4.1",
"@qavajs/po-playwright": "^0.0.9",
Expand Down
19 changes: 19 additions & 0 deletions src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,25 @@ When('I switch to {int} window', async function (index: number) {
po.driver = page;
});

/**
* Switch to window by title or url
* @param {string} matcher - url or title of window to switch
* @example I switch to 'google' window
*/
When('I switch to {string} window', async function (matcher: string) {
const urlOrTitle = await getValue(matcher);
const pages = context.pages();
for (const p of pages) {
if (p.url().includes(urlOrTitle) || (await p.title()).includes(urlOrTitle)) {
global.page = p;
//@ts-ignore
po.driver = p;
return;
}
}
throw new Error(`Page matching '${matcher}' is not found`);
});

/**
* Refresh current page
* @example I refresh page
Expand Down
10 changes: 8 additions & 2 deletions test-e2e/features/actions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,19 @@ Feature: actions
When I expect 'Frame Element' not to be visible
When I expect 'Inner Frame Element' not to be visible

Scenario: switch to tab by index
Scenario Outline: switch to tab by <test>
When I click 'New Tab Link'
When I wait 1000 ms
When I switch to 2 window
When I switch to <param> window
Then I expect current url to be equal '$framePage'
When I expect 'Frame Element' to be visible

Examples:
| test | param |
| index | 2 |
| title | 'Frame' |
| url | 'frame.html' |

Scenario: refresh page
When I type 'test value' to 'Input'
Then I expect text of 'Action' to be equal 'test value'
Expand Down
2 changes: 1 addition & 1 deletion test-e2e/features/waits.feature
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Feature: waits
Then I wait until text of 'Loading' to be equal '100%' (timeout: 3000)

Scenario: wait for property with timeout
Then I wait until 'value' property of 'Loading Input' to be equal '100%' (timeout: 3000)
Then I wait until 'value' property of 'Loading Input' to be equal '100%' (timeout: 5000)

Scenario: wait for attribute with timeout
Then I wait until 'style' attribute of 'Hidden Element' to contain 'hidden' (timeout: 3000)
Expand Down