-
Notifications
You must be signed in to change notification settings - Fork 217
Add support for multi-page web tests #3065
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Komoszek
wants to merge
14
commits into
master
Choose a base branch
from
feature/web-multi-tab-continued
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
13933a9
feat(web): add multi-tab browser support for web tests (#2871)
baslogic 432f952
Rename web automator naming to pages and refactor action params
Komoszek b6e65c4
Add switchToMainPage web action
Komoszek cd408f4
Align waitForPopup to mirror acceptNextDialog/dismissNextDialog
Komoszek 25ff113
Fix handlePatrolPlatformAction
Komoszek 7ac3729
Fix web integrations tests
Komoszek c196f73
Add close method to PageManager
Komoszek 828be16
Return page identifiers only in getPages method
Komoszek d59f2b5
Add getCurrentPageUrl web method
Komoszek 31cb856
Update changelog
Komoszek b1cb570
Add missing semicolon
Komoszek ebdffe0
Remove unused params
Komoszek 503cedc
Fix formatting
Komoszek 694a5dd
Add getCurrentPageUrl to known actions
Komoszek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
dev/e2e_app/patrol_test/web/web_example_multi_tab_navigation_test.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import '../common.dart'; | ||
|
|
||
| import 'web_example_app.dart'; | ||
|
|
||
| void main() { | ||
| patrol('interact with form in new page while navigating Flutter app', ( | ||
| $, | ||
| ) async { | ||
| await $.pumpWidgetAndSettle(const WebExampleApp()); | ||
|
|
||
| final formUrl = '${Uri.base.origin}/assets/assets/iframe_content.html'; | ||
| final newPageId = await $.platform.web.openNewPage(url: formUrl); | ||
| await $.pumpAndSettle(); | ||
| await Future<void>.delayed(const Duration(seconds: 2)); | ||
|
|
||
| final pages = await $.platform.web.getPages(); | ||
| expect(pages.length, 2); | ||
|
|
||
| // Fill form in the new page | ||
| await $.platform.web.switchToPage(pageId: newPageId); | ||
| await $.pumpAndSettle(); | ||
| await Future<void>.delayed(const Duration(seconds: 1)); | ||
|
|
||
| await $.platform.web.enterText( | ||
| WebSelector(cssOrXpath: '#test-input'), | ||
| text: 'Patrol multi-page test', | ||
| ); | ||
| await $.platform.web.tap(WebSelector(cssOrXpath: '#submit-button')); | ||
| await Future<void>.delayed(const Duration(seconds: 1)); | ||
|
|
||
| // Switch back and navigate the Flutter app | ||
| await $.platform.web.switchToMainPage(); | ||
| await $.pumpAndSettle(); | ||
|
|
||
| await $('Go to Page 1').scrollTo().tap(); | ||
| await $.pumpAndSettle(); | ||
| await Future<void>.delayed(const Duration(seconds: 2)); | ||
|
|
||
| expect($('This is Page 1'), findsOneWidget); | ||
|
|
||
| await $.platform.web.goBack(); | ||
| await $.pumpAndSettle(); | ||
| await Future<void>.delayed(const Duration(seconds: 2)); | ||
|
|
||
| expect($('This is the home page'), findsOneWidget); | ||
|
|
||
| await $.platform.web.closePage(pageId: newPageId); | ||
|
|
||
| final remaining = await $.platform.web.getPages(); | ||
| expect(remaining.length, 1); | ||
| }); | ||
| } | ||
104 changes: 104 additions & 0 deletions
104
dev/e2e_app/patrol_test/web/web_example_multi_tab_test.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| import 'dart:collection'; | ||
|
|
||
| import '../common.dart'; | ||
|
|
||
| import 'web_example_app.dart'; | ||
|
|
||
| void main() { | ||
| patrol('open external page, fill form, and return to Flutter app', ($) async { | ||
| await $.pumpWidgetAndSettle(const WebExampleApp()); | ||
|
|
||
| final formUrl = '${Uri.base.origin}/assets/assets/iframe_content.html'; | ||
| final newPageId = await $.platform.web.openNewPage(url: formUrl); | ||
| await $.pumpAndSettle(); | ||
| await Future<void>.delayed(const Duration(seconds: 2)); | ||
|
Komoszek marked this conversation as resolved.
|
||
|
|
||
| await $.platform.web.switchToPage(pageId: newPageId); | ||
| await $.pumpAndSettle(); | ||
| await Future<void>.delayed(const Duration(seconds: 1)); | ||
|
|
||
| final currentTab = await $.platform.web.getCurrentPage(); | ||
| expect(currentTab, newPageId); | ||
|
|
||
| final currentUrl = await $.platform.web.getCurrentPageUrl(); | ||
| expect(currentUrl, formUrl); | ||
|
|
||
| await $.platform.web.enterText( | ||
| WebSelector(cssOrXpath: '#test-input'), | ||
| text: 'Hello from new tab', | ||
| ); | ||
| await $.platform.web.tap(WebSelector(cssOrXpath: '#submit-button')); | ||
| await Future<void>.delayed(const Duration(seconds: 1)); | ||
|
|
||
| await $.platform.web.switchToMainPage(); | ||
| await $.pumpAndSettle(); | ||
|
|
||
| expect(await $.platform.web.getCurrentPage(), 'page_0'); | ||
| expect($('This is the home page'), findsOneWidget); | ||
|
|
||
| await $.platform.web.closePage(pageId: newPageId); | ||
| }); | ||
|
|
||
| patrol('open leancode.co, accept cookies, and close tab', ($) async { | ||
| await $.pumpWidgetAndSettle(const WebExampleApp()); | ||
|
|
||
| final newPageId = await $.platform.web.openNewPage( | ||
| url: 'https://leancode.co/', | ||
| ); | ||
| await $.pumpAndSettle(); | ||
| await Future<void>.delayed(const Duration(seconds: 3)); | ||
|
|
||
| await $.platform.web.switchToPage(pageId: newPageId); | ||
| await $.pumpAndSettle(); | ||
| await Future<void>.delayed(const Duration(seconds: 2)); | ||
|
|
||
| await $.platform.web.tap(WebSelector(text: 'Accept All')); | ||
| await Future<void>.delayed(const Duration(seconds: 1)); | ||
|
|
||
| await $.platform.web.switchToMainPage(); | ||
| await $.pumpAndSettle(); | ||
|
|
||
| expect($('This is the home page'), findsOneWidget); | ||
|
|
||
| await $.platform.web.closePage(pageId: newPageId); | ||
| }); | ||
|
|
||
| patrol('cross-tab cookies persist across browser context', ($) async { | ||
| await $.pumpWidgetAndSettle(const WebExampleApp()); | ||
|
|
||
| await $.platform.web.addCookie( | ||
| name: 'session', | ||
| value: 'abc123', | ||
| url: Uri.base.origin, | ||
| ); | ||
|
|
||
| var cookies = await $.platform.web.getCookies(); | ||
| var sessionCookie = cookies.firstWhere( | ||
| (c) => c['name'] == 'session', | ||
| orElse: LinkedHashMap<Object?, Object?>.new, | ||
| ); | ||
| expect(sessionCookie['value'], 'abc123'); | ||
|
|
||
| final formUrl = '${Uri.base.origin}/assets/assets/iframe_content.html'; | ||
| final newPageId = await $.platform.web.openNewPage(url: formUrl); | ||
| await $.pumpAndSettle(); | ||
| await Future<void>.delayed(const Duration(seconds: 2)); | ||
|
|
||
| await $.platform.web.switchToPage(pageId: newPageId); | ||
| await $.pumpAndSettle(); | ||
| await Future<void>.delayed(const Duration(seconds: 1)); | ||
|
|
||
| cookies = await $.platform.web.getCookies(); | ||
| sessionCookie = cookies.firstWhere( | ||
| (c) => c['name'] == 'session', | ||
| orElse: LinkedHashMap<Object?, Object?>.new, | ||
| ); | ||
| expect(sessionCookie['value'], 'abc123'); | ||
|
|
||
| await $.platform.web.switchToMainPage(); | ||
| await $.pumpAndSettle(); | ||
|
|
||
| await $.platform.web.clearCookies(); | ||
| await $.platform.web.closePage(pageId: newPageId); | ||
| }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.