Skip to content

Commit 278d13e

Browse files
added _I switch to 'IFrame' frame_ (#48)
* added _I switch to 'IFrame' frame_
1 parent 2e8829f commit 278d13e

File tree

9 files changed

+81
-11
lines changed

9 files changed

+81
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
66

77
## [0.0.23]
88
- :rocket: added types to global members
9+
- :rocket: added _I switch to 'IFrame' frame_
910

1011
## [0.0.22]
1112
- :beetle: fixed exports of mock and poDefine

package-lock.json

Lines changed: 7 additions & 7 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
@@ -26,7 +26,7 @@
2626
"@cucumber/cucumber": "^9.1.2",
2727
"@qavajs/cli": "^0.0.22",
2828
"@qavajs/console-formatter": "^0.2.1",
29-
"@qavajs/memory": "^1.4.0",
29+
"@qavajs/memory": "^1.4.1",
3030
"@qavajs/po-playwright": "^0.0.9",
3131
"@qavajs/webstorm-adapter": "^8.0.0",
3232
"@qavajs/xunit-formatter": "^0.0.4",

src/actions.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,19 @@ When('I switch to {int} frame', async function (index: number) {
9999
po.driver = page.frames()[index];
100100
});
101101

102+
/**
103+
* Switch to frame by alias
104+
* @param {string} index - alias to switch
105+
* @example I switch to 'IFrame' frame
106+
*/
107+
When('I switch to {string} frame', async function (frameAlias: string) {
108+
const frame = await getElement(frameAlias);
109+
const frameHandle = await frame.elementHandle();
110+
if (!frameHandle) throw new Error(`Frame '${frameHandle}' does not exist!`);
111+
// @ts-ignore
112+
po.driver = await frameHandle.contentFrame();
113+
});
114+
102115
/**
103116
* Switch to window by index
104117
* @param {number} index - index to switch

test-e2e/apps/actions.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<button id="confirm">Show alert in 3 sec</button>
1717
<button id="prompt">Show prompt</button>
1818

19-
<iframe src="frame.html" style="border: 1px solid black"></iframe>
19+
<iframe id="firstIframe" src="frame.html" title="firstIframe" style="border: 1px solid black"></iframe>
2020
<a id="newTabLink" href="frame.html" target="_blank">New tab</a>
2121
<label for="select"></label><select name="select" id="select">
2222
<option value="select one">one</option>

test-e2e/apps/frame.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
</head>
77
<body>
88
<div id="frameElement">Frame Element</div>
9+
<iframe id="innerIframe" src="innerFrame.html" title="innerIframe" style="border: 1px solid red"></iframe>
910
</body>
1011
</html>

test-e2e/apps/innerFrame.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Frame</title>
6+
</head>
7+
<body>
8+
<div id="innerFrameElement">Inner Frame Element</div>
9+
</body>
10+
</html>

test-e2e/features/actions.feature

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,50 @@ Feature: actions
4747
When I expect 'Button' to be visible
4848
When I expect 'Frame Element' not to be visible
4949

50+
Scenario: switch to page object frame
51+
When I expect 'Button' to be visible
52+
When I expect 'Frame Element' not to be visible
53+
When I switch to 'IFrame' frame
54+
When I expect 'Button' not to be visible
55+
When I expect 'Frame Element' to be visible
56+
When I switch to parent frame
57+
When I expect 'Button' to be visible
58+
When I expect 'Frame Element' not to be visible
59+
60+
Scenario: switch to frame in frame
61+
When I expect 'Button' to be visible
62+
When I expect 'Frame Element' not to be visible
63+
When I expect 'Inner Frame Element' not to be visible
64+
When I switch to 1 frame
65+
When I expect 'Button' not to be visible
66+
When I expect 'Frame Element' to be visible
67+
When I expect 'Inner Frame Element' not to be visible
68+
When I switch to 2 frame
69+
When I expect 'Button' not to be visible
70+
When I expect 'Frame Element' not to be visible
71+
When I expect 'Inner Frame Element' to be visible
72+
When I switch to parent frame
73+
When I expect 'Button' to be visible
74+
When I expect 'Frame Element' not to be visible
75+
When I expect 'Inner Frame Element' not to be visible
76+
77+
Scenario: switch to frame in frame using page object
78+
When I expect 'Button' to be visible
79+
When I expect 'Frame Element' not to be visible
80+
When I expect 'Inner Frame Element' not to be visible
81+
When I switch to 'IFrame' frame
82+
When I expect 'Button' not to be visible
83+
When I expect 'Frame Element' to be visible
84+
When I expect 'Inner Frame Element' not to be visible
85+
When I switch to 'Inner IFrame' frame
86+
When I expect 'Button' not to be visible
87+
When I expect 'Frame Element' not to be visible
88+
When I expect 'Inner Frame Element' to be visible
89+
When I switch to parent frame
90+
When I expect 'Button' to be visible
91+
When I expect 'Frame Element' not to be visible
92+
When I expect 'Inner Frame Element' not to be visible
93+
5094
Scenario: switch to tab by index
5195
When I click 'New Tab Link'
5296
When I wait 1000 ms

test-e2e/page_object/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ export default class App {
1212
Input = $('#input');
1313
Select = $('#select');
1414
Buttons = $$('.button');
15-
15+
IFrame = $('iframe#firstIframe');
16+
InnerIFrame = $('iframe#innerIframe');
1617
FrameElement = $('#frameElement');
17-
18+
InnerFrameElement = $('#innerFrameElement');
1819
NewTabLink = $('#newTabLink');
1920

2021
PresentElement = $('#present');

0 commit comments

Comments
 (0)