@serenity-js/protractor 2.33.1 → 3.0.0-rc.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +481 -0
- package/lib/adapter/ProtractorFrameworkAdapter.js +5 -0
- package/lib/adapter/ProtractorFrameworkAdapter.js.map +1 -1
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -2
- package/lib/index.js.map +1 -1
- package/lib/screenplay/abilities/{BrowseTheWeb.d.ts → BrowseTheWebWithProtractor.d.ts} +38 -191
- package/lib/screenplay/abilities/{BrowseTheWeb.js → BrowseTheWebWithProtractor.js} +129 -251
- package/lib/screenplay/abilities/BrowseTheWebWithProtractor.js.map +1 -0
- package/lib/screenplay/abilities/index.d.ts +1 -1
- package/lib/screenplay/abilities/index.js +1 -1
- package/lib/screenplay/abilities/index.js.map +1 -1
- package/lib/screenplay/index.d.ts +1 -0
- package/lib/screenplay/index.js +1 -0
- package/lib/screenplay/index.js.map +1 -1
- package/lib/screenplay/interactions/UseAngular.js +2 -2
- package/lib/screenplay/interactions/UseAngular.js.map +1 -1
- package/lib/screenplay/interactions/index.d.ts +0 -19
- package/lib/screenplay/interactions/index.js +0 -19
- package/lib/screenplay/interactions/index.js.map +1 -1
- package/lib/screenplay/models/ProtractorCookie.d.ts +11 -0
- package/lib/screenplay/models/ProtractorCookie.js +39 -0
- package/lib/screenplay/models/ProtractorCookie.js.map +1 -0
- package/lib/screenplay/models/ProtractorFrame.d.ts +10 -0
- package/lib/screenplay/models/ProtractorFrame.js +39 -0
- package/lib/screenplay/models/ProtractorFrame.js.map +1 -0
- package/lib/screenplay/models/ProtractorModalDialog.d.ts +11 -0
- package/lib/screenplay/models/ProtractorModalDialog.js +43 -0
- package/lib/screenplay/models/ProtractorModalDialog.js.map +1 -0
- package/lib/screenplay/models/ProtractorPage.d.ts +26 -0
- package/lib/screenplay/models/ProtractorPage.js +98 -0
- package/lib/screenplay/models/ProtractorPage.js.map +1 -0
- package/lib/screenplay/models/ProtractorPageElement.d.ts +21 -0
- package/lib/screenplay/models/ProtractorPageElement.js +230 -0
- package/lib/screenplay/models/ProtractorPageElement.js.map +1 -0
- package/lib/screenplay/models/index.d.ts +5 -0
- package/lib/screenplay/{questions/lists → models}/index.js +5 -1
- package/lib/screenplay/models/index.js.map +1 -0
- package/lib/screenplay/models/locators/ProtractorLocator.d.ts +9 -0
- package/lib/screenplay/models/locators/ProtractorLocator.js +28 -0
- package/lib/screenplay/models/locators/ProtractorLocator.js.map +1 -0
- package/lib/screenplay/models/locators/ProtractorNativeElementRoot.d.ts +5 -0
- package/lib/screenplay/{interactions/EnterBuilder.js → models/locators/ProtractorNativeElementRoot.js} +1 -1
- package/lib/screenplay/models/locators/ProtractorNativeElementRoot.js.map +1 -0
- package/lib/screenplay/models/locators/index.d.ts +2 -0
- package/lib/{stage/crew → screenplay/models/locators}/index.js +2 -1
- package/lib/screenplay/models/locators/index.js.map +1 -0
- package/lib/{promiseOf.d.ts → screenplay/promised.d.ts} +1 -1
- package/lib/{promiseOf.js → screenplay/promised.js} +4 -4
- package/lib/screenplay/promised.js.map +1 -0
- package/lib/screenplay/questions/ProtractorParam.d.ts +24 -29
- package/lib/screenplay/questions/ProtractorParam.js +26 -33
- package/lib/screenplay/questions/ProtractorParam.js.map +1 -1
- package/lib/screenplay/questions/index.d.ts +0 -13
- package/lib/screenplay/questions/index.js +0 -16
- package/lib/screenplay/questions/index.js.map +1 -1
- package/lib/screenplay/unpromisedWebElement.d.ts +11 -0
- package/lib/screenplay/unpromisedWebElement.js +24 -0
- package/lib/screenplay/unpromisedWebElement.js.map +1 -0
- package/package.json +19 -20
- package/src/adapter/ProtractorFrameworkAdapter.ts +5 -0
- package/src/index.ts +0 -2
- package/src/screenplay/abilities/{BrowseTheWeb.ts → BrowseTheWebWithProtractor.ts} +148 -263
- package/src/screenplay/abilities/index.ts +1 -1
- package/src/screenplay/index.ts +1 -0
- package/src/screenplay/interactions/UseAngular.ts +3 -3
- package/src/screenplay/interactions/index.ts +0 -19
- package/src/screenplay/models/ProtractorCookie.ts +41 -0
- package/src/screenplay/models/ProtractorFrame.ts +44 -0
- package/src/screenplay/models/ProtractorModalDialog.ts +49 -0
- package/src/screenplay/models/ProtractorPage.ts +124 -0
- package/src/screenplay/models/ProtractorPageElement.ts +285 -0
- package/src/screenplay/models/index.ts +6 -0
- package/src/screenplay/models/locators/ProtractorLocator.ts +50 -0
- package/src/screenplay/models/locators/ProtractorNativeElementRoot.ts +6 -0
- package/src/screenplay/models/locators/index.ts +2 -0
- package/src/{promiseOf.ts → screenplay/promised.ts} +1 -1
- package/src/screenplay/questions/ProtractorParam.ts +29 -38
- package/src/screenplay/questions/index.ts +0 -13
- package/src/screenplay/unpromisedWebElement.ts +25 -0
- package/lib/expectations/ElementFinderExpectation.d.ts +0 -11
- package/lib/expectations/ElementFinderExpectation.js +0 -24
- package/lib/expectations/ElementFinderExpectation.js.map +0 -1
- package/lib/expectations/index.d.ts +0 -6
- package/lib/expectations/index.js +0 -19
- package/lib/expectations/index.js.map +0 -1
- package/lib/expectations/isActive.d.ts +0 -13
- package/lib/expectations/isActive.js +0 -19
- package/lib/expectations/isActive.js.map +0 -1
- package/lib/expectations/isClickable.d.ts +0 -13
- package/lib/expectations/isClickable.js +0 -22
- package/lib/expectations/isClickable.js.map +0 -1
- package/lib/expectations/isEnabled.d.ts +0 -13
- package/lib/expectations/isEnabled.js +0 -19
- package/lib/expectations/isEnabled.js.map +0 -1
- package/lib/expectations/isPresent.d.ts +0 -14
- package/lib/expectations/isPresent.js +0 -20
- package/lib/expectations/isPresent.js.map +0 -1
- package/lib/expectations/isSelected.d.ts +0 -13
- package/lib/expectations/isSelected.js +0 -22
- package/lib/expectations/isSelected.js.map +0 -1
- package/lib/expectations/isVisible.d.ts +0 -13
- package/lib/expectations/isVisible.js +0 -25
- package/lib/expectations/isVisible.js.map +0 -1
- package/lib/promiseOf.js.map +0 -1
- package/lib/screenplay/abilities/BrowseTheWeb.js.map +0 -1
- package/lib/screenplay/interactions/Accept.d.ts +0 -81
- package/lib/screenplay/interactions/Accept.js +0 -95
- package/lib/screenplay/interactions/Accept.js.map +0 -1
- package/lib/screenplay/interactions/Clear.d.ts +0 -88
- package/lib/screenplay/interactions/Clear.js +0 -121
- package/lib/screenplay/interactions/Clear.js.map +0 -1
- package/lib/screenplay/interactions/Click.d.ts +0 -81
- package/lib/screenplay/interactions/Click.js +0 -95
- package/lib/screenplay/interactions/Click.js.map +0 -1
- package/lib/screenplay/interactions/Close.d.ts +0 -89
- package/lib/screenplay/interactions/Close.js +0 -169
- package/lib/screenplay/interactions/Close.js.map +0 -1
- package/lib/screenplay/interactions/DeleteCookies.d.ts +0 -72
- package/lib/screenplay/interactions/DeleteCookies.js +0 -149
- package/lib/screenplay/interactions/DeleteCookies.js.map +0 -1
- package/lib/screenplay/interactions/Dismiss.d.ts +0 -85
- package/lib/screenplay/interactions/Dismiss.js +0 -99
- package/lib/screenplay/interactions/Dismiss.js.map +0 -1
- package/lib/screenplay/interactions/DoubleClick.d.ts +0 -99
- package/lib/screenplay/interactions/DoubleClick.js +0 -121
- package/lib/screenplay/interactions/DoubleClick.js.map +0 -1
- package/lib/screenplay/interactions/Enter.d.ts +0 -81
- package/lib/screenplay/interactions/Enter.js +0 -96
- package/lib/screenplay/interactions/Enter.js.map +0 -1
- package/lib/screenplay/interactions/EnterBuilder.d.ts +0 -27
- package/lib/screenplay/interactions/EnterBuilder.js.map +0 -1
- package/lib/screenplay/interactions/ExecuteScript.d.ts +0 -171
- package/lib/screenplay/interactions/ExecuteScript.js +0 -291
- package/lib/screenplay/interactions/ExecuteScript.js.map +0 -1
- package/lib/screenplay/interactions/Hover.d.ts +0 -86
- package/lib/screenplay/interactions/Hover.js +0 -103
- package/lib/screenplay/interactions/Hover.js.map +0 -1
- package/lib/screenplay/interactions/Navigate.d.ts +0 -149
- package/lib/screenplay/interactions/Navigate.js +0 -345
- package/lib/screenplay/interactions/Navigate.js.map +0 -1
- package/lib/screenplay/interactions/Press.d.ts +0 -90
- package/lib/screenplay/interactions/Press.js +0 -127
- package/lib/screenplay/interactions/Press.js.map +0 -1
- package/lib/screenplay/interactions/PressBuilder.d.ts +0 -27
- package/lib/screenplay/interactions/PressBuilder.js +0 -3
- package/lib/screenplay/interactions/PressBuilder.js.map +0 -1
- package/lib/screenplay/interactions/ResizeBrowserWindow.d.ts +0 -69
- package/lib/screenplay/interactions/ResizeBrowserWindow.js +0 -144
- package/lib/screenplay/interactions/ResizeBrowserWindow.js.map +0 -1
- package/lib/screenplay/interactions/RightClick.d.ts +0 -97
- package/lib/screenplay/interactions/RightClick.js +0 -113
- package/lib/screenplay/interactions/RightClick.js.map +0 -1
- package/lib/screenplay/interactions/Scroll.d.ts +0 -83
- package/lib/screenplay/interactions/Scroll.js +0 -98
- package/lib/screenplay/interactions/Scroll.js.map +0 -1
- package/lib/screenplay/interactions/Select.d.ts +0 -212
- package/lib/screenplay/interactions/Select.js +0 -342
- package/lib/screenplay/interactions/Select.js.map +0 -1
- package/lib/screenplay/interactions/SelectBuilder.d.ts +0 -33
- package/lib/screenplay/interactions/SelectBuilder.js +0 -3
- package/lib/screenplay/interactions/SelectBuilder.js.map +0 -1
- package/lib/screenplay/interactions/Switch.d.ts +0 -210
- package/lib/screenplay/interactions/Switch.js +0 -345
- package/lib/screenplay/interactions/Switch.js.map +0 -1
- package/lib/screenplay/interactions/TakeScreenshot.d.ts +0 -67
- package/lib/screenplay/interactions/TakeScreenshot.js +0 -86
- package/lib/screenplay/interactions/TakeScreenshot.js.map +0 -1
- package/lib/screenplay/interactions/Wait.d.ts +0 -147
- package/lib/screenplay/interactions/Wait.js +0 -247
- package/lib/screenplay/interactions/Wait.js.map +0 -1
- package/lib/screenplay/interactions/WaitBuilder.d.ts +0 -33
- package/lib/screenplay/interactions/WaitBuilder.js +0 -3
- package/lib/screenplay/interactions/WaitBuilder.js.map +0 -1
- package/lib/screenplay/questions/Attribute.d.ts +0 -29
- package/lib/screenplay/questions/Attribute.js +0 -56
- package/lib/screenplay/questions/Attribute.js.map +0 -1
- package/lib/screenplay/questions/Browser.d.ts +0 -47
- package/lib/screenplay/questions/Browser.js +0 -55
- package/lib/screenplay/questions/Browser.js.map +0 -1
- package/lib/screenplay/questions/CSSClasses.d.ts +0 -94
- package/lib/screenplay/questions/CSSClasses.js +0 -118
- package/lib/screenplay/questions/CSSClasses.js.map +0 -1
- package/lib/screenplay/questions/Cookie.d.ts +0 -9
- package/lib/screenplay/questions/Cookie.js +0 -65
- package/lib/screenplay/questions/Cookie.js.map +0 -1
- package/lib/screenplay/questions/LastScriptExecution.d.ts +0 -14
- package/lib/screenplay/questions/LastScriptExecution.js +0 -22
- package/lib/screenplay/questions/LastScriptExecution.js.map +0 -1
- package/lib/screenplay/questions/ModalDialog.d.ts +0 -120
- package/lib/screenplay/questions/ModalDialog.js +0 -142
- package/lib/screenplay/questions/ModalDialog.js.map +0 -1
- package/lib/screenplay/questions/Pick.d.ts +0 -72
- package/lib/screenplay/questions/Pick.js +0 -254
- package/lib/screenplay/questions/Pick.js.map +0 -1
- package/lib/screenplay/questions/Selected.d.ts +0 -185
- package/lib/screenplay/questions/Selected.js +0 -254
- package/lib/screenplay/questions/Selected.js.map +0 -1
- package/lib/screenplay/questions/Value.d.ts +0 -47
- package/lib/screenplay/questions/Value.js +0 -67
- package/lib/screenplay/questions/Value.js.map +0 -1
- package/lib/screenplay/questions/Website.d.ts +0 -15
- package/lib/screenplay/questions/Website.js +0 -25
- package/lib/screenplay/questions/Website.js.map +0 -1
- package/lib/screenplay/questions/Window.d.ts +0 -23
- package/lib/screenplay/questions/Window.js +0 -28
- package/lib/screenplay/questions/Window.js.map +0 -1
- package/lib/screenplay/questions/lists/ElementArrayFinderListAdapter.d.ts +0 -89
- package/lib/screenplay/questions/lists/ElementArrayFinderListAdapter.js +0 -138
- package/lib/screenplay/questions/lists/ElementArrayFinderListAdapter.js.map +0 -1
- package/lib/screenplay/questions/lists/index.d.ts +0 -1
- package/lib/screenplay/questions/lists/index.js.map +0 -1
- package/lib/screenplay/questions/targets/Target.d.ts +0 -168
- package/lib/screenplay/questions/targets/Target.js +0 -190
- package/lib/screenplay/questions/targets/Target.js.map +0 -1
- package/lib/screenplay/questions/targets/TargetElement.d.ts +0 -50
- package/lib/screenplay/questions/targets/TargetElement.js +0 -62
- package/lib/screenplay/questions/targets/TargetElement.js.map +0 -1
- package/lib/screenplay/questions/targets/TargetElements.d.ts +0 -102
- package/lib/screenplay/questions/targets/TargetElements.js +0 -124
- package/lib/screenplay/questions/targets/TargetElements.js.map +0 -1
- package/lib/screenplay/questions/targets/TargetNestedElement.d.ts +0 -49
- package/lib/screenplay/questions/targets/TargetNestedElement.js +0 -61
- package/lib/screenplay/questions/targets/TargetNestedElement.js.map +0 -1
- package/lib/screenplay/questions/targets/TargetNestedElements.d.ts +0 -101
- package/lib/screenplay/questions/targets/TargetNestedElements.js +0 -123
- package/lib/screenplay/questions/targets/TargetNestedElements.js.map +0 -1
- package/lib/screenplay/questions/targets/builders.d.ts +0 -8
- package/lib/screenplay/questions/targets/builders.js +0 -3
- package/lib/screenplay/questions/targets/builders.js.map +0 -1
- package/lib/screenplay/questions/targets/index.d.ts +0 -5
- package/lib/screenplay/questions/targets/index.js +0 -18
- package/lib/screenplay/questions/targets/index.js.map +0 -1
- package/lib/screenplay/questions/targets/override.d.ts +0 -7
- package/lib/screenplay/questions/targets/override.js +0 -21
- package/lib/screenplay/questions/targets/override.js.map +0 -1
- package/lib/screenplay/questions/text/Text.d.ts +0 -41
- package/lib/screenplay/questions/text/Text.js +0 -50
- package/lib/screenplay/questions/text/Text.js.map +0 -1
- package/lib/screenplay/questions/text/TextOfMultipleElements.d.ts +0 -23
- package/lib/screenplay/questions/text/TextOfMultipleElements.js +0 -37
- package/lib/screenplay/questions/text/TextOfMultipleElements.js.map +0 -1
- package/lib/screenplay/questions/text/TextOfSingleElement.d.ts +0 -23
- package/lib/screenplay/questions/text/TextOfSingleElement.js +0 -35
- package/lib/screenplay/questions/text/TextOfSingleElement.js.map +0 -1
- package/lib/screenplay/questions/text/index.d.ts +0 -1
- package/lib/screenplay/questions/text/index.js +0 -14
- package/lib/screenplay/questions/text/index.js.map +0 -1
- package/lib/screenplay/withAnswerOf.d.ts +0 -8
- package/lib/screenplay/withAnswerOf.js +0 -18
- package/lib/screenplay/withAnswerOf.js.map +0 -1
- package/lib/stage/crew/index.d.ts +0 -1
- package/lib/stage/crew/index.js.map +0 -1
- package/lib/stage/crew/photographer/Photographer.d.ts +0 -83
- package/lib/stage/crew/photographer/Photographer.js +0 -102
- package/lib/stage/crew/photographer/Photographer.js.map +0 -1
- package/lib/stage/crew/photographer/index.d.ts +0 -2
- package/lib/stage/crew/photographer/index.js +0 -15
- package/lib/stage/crew/photographer/index.js.map +0 -1
- package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.d.ts +0 -28
- package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.js +0 -65
- package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.js.map +0 -1
- package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.d.ts +0 -18
- package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.js +0 -30
- package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.js.map +0 -1
- package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.d.ts +0 -17
- package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.js +0 -28
- package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.js.map +0 -1
- package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.d.ts +0 -19
- package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.js +0 -28
- package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.js.map +0 -1
- package/lib/stage/crew/photographer/strategies/index.d.ts +0 -4
- package/lib/stage/crew/photographer/strategies/index.js +0 -17
- package/lib/stage/crew/photographer/strategies/index.js.map +0 -1
- package/lib/stage/index.d.ts +0 -1
- package/lib/stage/index.js +0 -14
- package/lib/stage/index.js.map +0 -1
- package/src/expectations/ElementFinderExpectation.ts +0 -29
- package/src/expectations/index.ts +0 -6
- package/src/expectations/isActive.ts +0 -24
- package/src/expectations/isClickable.ts +0 -20
- package/src/expectations/isEnabled.ts +0 -18
- package/src/expectations/isPresent.ts +0 -19
- package/src/expectations/isSelected.ts +0 -23
- package/src/expectations/isVisible.ts +0 -27
- package/src/screenplay/interactions/Accept.ts +0 -95
- package/src/screenplay/interactions/Clear.ts +0 -130
- package/src/screenplay/interactions/Click.ts +0 -96
- package/src/screenplay/interactions/Close.ts +0 -184
- package/src/screenplay/interactions/DeleteCookies.ts +0 -154
- package/src/screenplay/interactions/Dismiss.ts +0 -99
- package/src/screenplay/interactions/DoubleClick.ts +0 -124
- package/src/screenplay/interactions/Enter.ts +0 -104
- package/src/screenplay/interactions/EnterBuilder.ts +0 -29
- package/src/screenplay/interactions/ExecuteScript.ts +0 -325
- package/src/screenplay/interactions/Hover.ts +0 -106
- package/src/screenplay/interactions/Navigate.ts +0 -363
- package/src/screenplay/interactions/Press.ts +0 -137
- package/src/screenplay/interactions/PressBuilder.ts +0 -29
- package/src/screenplay/interactions/ResizeBrowserWindow.ts +0 -148
- package/src/screenplay/interactions/RightClick.ts +0 -114
- package/src/screenplay/interactions/Scroll.ts +0 -99
- package/src/screenplay/interactions/Select.ts +0 -402
- package/src/screenplay/interactions/SelectBuilder.ts +0 -35
- package/src/screenplay/interactions/Switch.ts +0 -393
- package/src/screenplay/interactions/TakeScreenshot.ts +0 -89
- package/src/screenplay/interactions/Wait.ts +0 -267
- package/src/screenplay/interactions/WaitBuilder.ts +0 -35
- package/src/screenplay/questions/Attribute.ts +0 -67
- package/src/screenplay/questions/Browser.ts +0 -55
- package/src/screenplay/questions/CSSClasses.ts +0 -121
- package/src/screenplay/questions/Cookie.ts +0 -70
- package/src/screenplay/questions/LastScriptExecution.ts +0 -21
- package/src/screenplay/questions/ModalDialog.ts +0 -149
- package/src/screenplay/questions/Pick.ts +0 -334
- package/src/screenplay/questions/Selected.ts +0 -268
- package/src/screenplay/questions/Value.ts +0 -73
- package/src/screenplay/questions/Website.ts +0 -27
- package/src/screenplay/questions/Window.ts +0 -29
- package/src/screenplay/questions/lists/ElementArrayFinderListAdapter.ts +0 -158
- package/src/screenplay/questions/lists/index.ts +0 -1
- package/src/screenplay/questions/targets/Target.ts +0 -198
- package/src/screenplay/questions/targets/TargetElement.ts +0 -70
- package/src/screenplay/questions/targets/TargetElements.ts +0 -142
- package/src/screenplay/questions/targets/TargetNestedElement.ts +0 -71
- package/src/screenplay/questions/targets/TargetNestedElements.ts +0 -142
- package/src/screenplay/questions/targets/builders.ts +0 -10
- package/src/screenplay/questions/targets/index.ts +0 -5
- package/src/screenplay/questions/targets/override.ts +0 -17
- package/src/screenplay/questions/text/Text.ts +0 -55
- package/src/screenplay/questions/text/TextOfMultipleElements.ts +0 -40
- package/src/screenplay/questions/text/TextOfSingleElement.ts +0 -37
- package/src/screenplay/questions/text/index.ts +0 -1
- package/src/screenplay/withAnswerOf.ts +0 -19
- package/src/stage/crew/index.ts +0 -1
- package/src/stage/crew/photographer/Photographer.ts +0 -108
- package/src/stage/crew/photographer/index.ts +0 -2
- package/src/stage/crew/photographer/strategies/PhotoTakingStrategy.ts +0 -102
- package/src/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.ts +0 -28
- package/src/stage/crew/photographer/strategies/TakePhotosOfFailures.ts +0 -26
- package/src/stage/crew/photographer/strategies/TakePhotosOfInteractions.ts +0 -26
- package/src/stage/crew/photographer/strategies/index.ts +0 -4
- package/src/stage/index.ts +0 -1
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { ConfigurationError, Duration, LogicError } from '@serenity-js/core';
|
|
2
|
+
import { BrowserCapabilities, BrowseTheWeb, ByCss, ByCssContainingText, ById, ByTagName, ByXPath, Cookie, CookieData, Frame, Key, ModalDialog, Page, Selector } from '@serenity-js/web';
|
|
3
|
+
import { by, ElementFinder, ProtractorBrowser } from 'protractor';
|
|
4
|
+
import { Capabilities } from 'selenium-webdriver';
|
|
4
5
|
|
|
5
|
-
import {
|
|
6
|
+
import { ProtractorCookie, ProtractorFrame, ProtractorModalDialog, ProtractorPage, ProtractorPageElement } from '../models';
|
|
7
|
+
import { ProtractorLocator, ProtractorNativeElementRoot } from '../models/locators';
|
|
8
|
+
import { promised } from '../promised';
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* @desc
|
|
@@ -33,288 +36,178 @@ import { promiseOf } from '../../promiseOf';
|
|
|
33
36
|
* @implements {@serenity-js/core/lib/screenplay~Ability}
|
|
34
37
|
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
35
38
|
*/
|
|
36
|
-
export class BrowseTheWeb
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @private
|
|
40
|
-
*/
|
|
41
|
-
private lastScriptExecutionSummary: LastScriptExecutionSummary;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @private
|
|
45
|
-
*/
|
|
46
|
-
private originalWindowHandle: string;
|
|
39
|
+
export class BrowseTheWebWithProtractor extends BrowseTheWeb<ElementFinder, ProtractorNativeElementRoot> {
|
|
47
40
|
|
|
48
41
|
/**
|
|
49
42
|
* @desc
|
|
50
43
|
* Ability to interact with web front-ends using a given protractor browser instance.
|
|
51
44
|
*
|
|
52
45
|
* @param {ProtractorBrowser} browser
|
|
53
|
-
* @returns {
|
|
46
|
+
* @returns {BrowseTheWebWithProtractor}
|
|
54
47
|
*/
|
|
55
|
-
static using(browser: ProtractorBrowser):
|
|
56
|
-
return new
|
|
48
|
+
static using(browser: ProtractorBrowser): BrowseTheWebWithProtractor {
|
|
49
|
+
return new BrowseTheWebWithProtractor(browser);
|
|
57
50
|
}
|
|
58
51
|
|
|
59
52
|
/**
|
|
60
|
-
* @
|
|
61
|
-
* Used to access the Actor's ability to {@link BrowseTheWeb} from within the {@link Interaction} classes,
|
|
62
|
-
* such as {@link Navigate}.
|
|
63
|
-
*
|
|
64
|
-
* @param {UsesAbilities} actor
|
|
65
|
-
* @return {BrowseTheWeb}
|
|
53
|
+
* @private
|
|
66
54
|
*/
|
|
67
|
-
|
|
68
|
-
return actor.abilityTo(BrowseTheWeb);
|
|
69
|
-
}
|
|
55
|
+
private lastScriptExecutionSummary: LastScriptExecutionSummary;
|
|
70
56
|
|
|
71
57
|
/**
|
|
72
58
|
* @param {ProtractorBrowser} browser
|
|
73
59
|
* An instance of a protractor browser
|
|
74
60
|
*/
|
|
75
61
|
constructor(protected browser: ProtractorBrowser) {
|
|
62
|
+
super(new Map()
|
|
63
|
+
.set(ByCss, (selector: ByCss) =>
|
|
64
|
+
// todo: this is a temporary experiment; target state is for all CSS selectors to support Shadow DOM by default
|
|
65
|
+
ProtractorLocator.createRootLocator(this.browser, selector,
|
|
66
|
+
selector.value.startsWith('>>>') && !! by.shadowDomCss
|
|
67
|
+
? by.shadowDomCss(selector.value.replace('>>>', ''))
|
|
68
|
+
: by.css(selector.value))
|
|
69
|
+
)
|
|
70
|
+
.set(ByCssContainingText, (selector: ByCssContainingText) => ProtractorLocator.createRootLocator(this.browser, selector, by.cssContainingText(selector.value, selector.text)))
|
|
71
|
+
.set(ById, (selector: ById) => ProtractorLocator.createRootLocator(this.browser, selector, by.id(selector.value)))
|
|
72
|
+
.set(ByTagName, (selector: ByTagName) => ProtractorLocator.createRootLocator(this.browser, selector, by.tagName(selector.value)))
|
|
73
|
+
.set(ByXPath, (selector: ByXPath) => ProtractorLocator.createRootLocator(this.browser, selector, by.xpath(selector.value)))
|
|
74
|
+
);
|
|
76
75
|
}
|
|
77
76
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
* @returns {Promise<void>}
|
|
87
|
-
*/
|
|
88
|
-
get(destination: string, timeoutInMillis?: number): Promise<void> {
|
|
89
|
-
return promiseOf(this.browser.get(destination, timeoutInMillis)
|
|
90
|
-
.then(() => this.browser.getWindowHandle())
|
|
91
|
-
.then(handle => {
|
|
92
|
-
this.originalWindowHandle = handle;
|
|
93
|
-
}),
|
|
94
|
-
);
|
|
77
|
+
async browserCapabilities(): Promise<BrowserCapabilities> {
|
|
78
|
+
const capabilities = await promised(this.browser.getCapabilities());
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
platformName: capabilities.get('platform'),
|
|
82
|
+
browserName: capabilities.get('browserName'),
|
|
83
|
+
browserVersion: capabilities.get('version'),
|
|
84
|
+
};
|
|
95
85
|
}
|
|
96
86
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
* Interface for navigating back and forth in the browser history.
|
|
100
|
-
*
|
|
101
|
-
* @returns {Navigation}
|
|
102
|
-
*/
|
|
103
|
-
navigate(): Navigation {
|
|
104
|
-
return this.browser.navigate();
|
|
87
|
+
async cookie(name: string): Promise<Cookie> {
|
|
88
|
+
return new ProtractorCookie(this.browser, name);
|
|
105
89
|
}
|
|
106
90
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
91
|
+
async setCookie(cookieData: CookieData): Promise<void> {
|
|
92
|
+
return promised(this.browser.manage().addCookie({
|
|
93
|
+
name: cookieData.name,
|
|
94
|
+
value: cookieData.value,
|
|
95
|
+
path: cookieData.path,
|
|
96
|
+
domain: cookieData.domain,
|
|
97
|
+
secure: cookieData.secure,
|
|
98
|
+
httpOnly: cookieData.httpOnly,
|
|
99
|
+
expiry: cookieData.expiry
|
|
100
|
+
? cookieData.expiry.toSeconds()
|
|
101
|
+
: undefined,
|
|
102
|
+
}));
|
|
118
103
|
}
|
|
119
104
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
* Interface for managing browser and driver state.
|
|
123
|
-
*
|
|
124
|
-
* @returns {Options}
|
|
125
|
-
*
|
|
126
|
-
* @see https://www.selenium.dev/selenium/docs/api/javascript/module/selenium-webdriver/lib/webdriver_exports_WebDriver.html#manage
|
|
127
|
-
*/
|
|
128
|
-
manage(): Options {
|
|
129
|
-
/*
|
|
130
|
-
this.browser.manage().deleteCookie();
|
|
131
|
-
this.browser.manage().deleteAllCookies();
|
|
132
|
-
return this.browser.manage().getCookie('asd');
|
|
133
|
-
*/
|
|
134
|
-
|
|
135
|
-
return this.browser.manage();
|
|
105
|
+
deleteAllCookies(): Promise<void> {
|
|
106
|
+
return promised(this.browser.manage().deleteAllCookies());
|
|
136
107
|
}
|
|
137
108
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
* Changes focus to the active modal dialog,
|
|
141
|
-
* such as those opened by
|
|
142
|
-
* [`Window.alert()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/alert),
|
|
143
|
-
* [`Window.prompt()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt), or
|
|
144
|
-
* [`Window.confirm()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/confirm).
|
|
145
|
-
*
|
|
146
|
-
* The returned promise will be rejected with an [`error.NoSuchAlertError`](https://www.selenium.dev/selenium/docs/api/javascript/module/selenium-webdriver/lib/error_exports_NoSuchAlertError.html)
|
|
147
|
-
* if there are no open alerts.
|
|
148
|
-
*
|
|
149
|
-
* @returns {AlertPromise}
|
|
150
|
-
*
|
|
151
|
-
* @see https://www.selenium.dev/selenium/docs/api/javascript/module/selenium-webdriver/lib/webdriver_exports_TargetLocator.html#alert
|
|
152
|
-
*/
|
|
153
|
-
alert(): AlertPromise {
|
|
154
|
-
return this.browser.switchTo().alert();
|
|
109
|
+
navigateTo(destination: string): Promise<void> {
|
|
110
|
+
return promised(this.browser.get(destination));
|
|
155
111
|
}
|
|
156
112
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
* Switches the focus to a [`frame`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/frame) or
|
|
160
|
-
* [`iframe`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe) identified by `elementOrIndexOrName`,
|
|
161
|
-
* which can be specified either as {@link selenium-webdriver~WebElement}, the name of the frame, or its index.
|
|
162
|
-
*
|
|
163
|
-
* @param {number | string | WebElement} elementOrIndexOrName
|
|
164
|
-
*
|
|
165
|
-
* @returns {Promise<void>}
|
|
166
|
-
*/
|
|
167
|
-
switchToFrame(elementOrIndexOrName: number | string | WebElement | WebElementPromise): Promise<void> {
|
|
168
|
-
// incorrect type definition in selenium-webdriver prevents us from providing a string arg
|
|
169
|
-
return promiseOf(this.browser.switchTo().frame(elementOrIndexOrName as any));
|
|
113
|
+
navigateBack(): Promise<void> {
|
|
114
|
+
return promised(this.browser.navigate().back());
|
|
170
115
|
}
|
|
171
116
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
* Switches the focus from any [`frame`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/frame) or
|
|
175
|
-
* [`iframe`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe) back to its parent iframe.
|
|
176
|
-
*
|
|
177
|
-
* @returns {Promise<void>}
|
|
178
|
-
*/
|
|
179
|
-
switchToParentFrame(): Promise<void> {
|
|
180
|
-
return promiseOf(this.browser.driver.switchToParentFrame());
|
|
117
|
+
navigateForward(): Promise<void> {
|
|
118
|
+
return promised(this.browser.navigate().forward());
|
|
181
119
|
}
|
|
182
120
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
* Switches the focus from any [`frame`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/frame)
|
|
186
|
-
* or [`iframe`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe) back to default content,
|
|
187
|
-
* a.k.a. "the main window".
|
|
188
|
-
*
|
|
189
|
-
* @returns {Promise<void>}
|
|
190
|
-
*/
|
|
191
|
-
switchToDefaultContent(): Promise<void> {
|
|
192
|
-
return promiseOf(this.browser.switchTo().defaultContent());
|
|
121
|
+
reloadPage(): Promise<void> {
|
|
122
|
+
return promised(this.browser.navigate().refresh());
|
|
193
123
|
}
|
|
194
124
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
* Switches browser window/tab to the one identified by `nameOrHandleOrIndex`,
|
|
198
|
-
* which can be specified as the name of the window to switch to, its handle, or numeric index.
|
|
199
|
-
*
|
|
200
|
-
* @param {string | number} nameOrHandleOrIndex
|
|
201
|
-
*
|
|
202
|
-
* @returns {Promise<void>}
|
|
203
|
-
*/
|
|
204
|
-
switchToWindow(nameOrHandleOrIndex: string | number): Promise<void> {
|
|
205
|
-
return typeof nameOrHandleOrIndex === 'string'
|
|
206
|
-
? this.switchToWindowByNameOrHandle(nameOrHandleOrIndex)
|
|
207
|
-
: this.switchToWindowByIndex(nameOrHandleOrIndex);
|
|
125
|
+
waitFor(duration: Duration): Promise<void> {
|
|
126
|
+
return promised(this.browser.sleep(duration.inMilliseconds()));
|
|
208
127
|
}
|
|
209
128
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
* @private
|
|
213
|
-
*/
|
|
214
|
-
private switchToWindowByNameOrHandle(nameOrHandle: string): Promise<void> {
|
|
215
|
-
return promiseOf(this.browser.switchTo().window(nameOrHandle));
|
|
129
|
+
waitUntil(condition: () => boolean | Promise<boolean>, timeout: Duration): Promise<void> {
|
|
130
|
+
return promised(this.browser.wait(condition, timeout.inMilliseconds())) as unknown as Promise<void>;
|
|
216
131
|
}
|
|
217
132
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
private switchToWindowByIndex(index: number): Promise<void> {
|
|
223
|
-
return promiseOf(this.browser.getAllWindowHandles().then(handles => {
|
|
224
|
-
const handle = handles[index];
|
|
133
|
+
async sendKeys(keys: (string | Key)[]): Promise<void> {
|
|
134
|
+
function isModifier(maybeKey: string | Key): boolean {
|
|
135
|
+
return Key.isKey(maybeKey) && maybeKey.isModifier;
|
|
136
|
+
}
|
|
225
137
|
|
|
226
|
-
|
|
227
|
-
|
|
138
|
+
function asCodePoint(maybeKey: string | Key): string {
|
|
139
|
+
if (! Key.isKey(maybeKey)) {
|
|
140
|
+
return maybeKey;
|
|
228
141
|
}
|
|
229
142
|
|
|
230
|
-
return
|
|
231
|
-
}
|
|
232
|
-
}
|
|
143
|
+
return maybeKey.utf16codePoint;
|
|
144
|
+
}
|
|
233
145
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
switchToOriginalWindow(): Promise<void> {
|
|
241
|
-
return this.originalWindowHandle
|
|
242
|
-
? promiseOf(this.browser.switchTo().window(this.originalWindowHandle))
|
|
243
|
-
: Promise.resolve();
|
|
244
|
-
}
|
|
146
|
+
// keyDown for any modifier keys and sendKeys otherwise
|
|
147
|
+
const keyDownActions = keys.reduce((actions, key) => {
|
|
148
|
+
return isModifier(key)
|
|
149
|
+
? actions.keyDown(asCodePoint(key))
|
|
150
|
+
: actions.sendKeys(asCodePoint(key))
|
|
151
|
+
}, this.browser.actions());
|
|
245
152
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
*/
|
|
255
|
-
getOriginalWindowHandle(): Promise<string> {
|
|
256
|
-
return Promise.resolve(this.originalWindowHandle);
|
|
153
|
+
// keyUp for any modifier keys, ignore for regular keys
|
|
154
|
+
const keyUpActions = keys.reduce((actions, key) => {
|
|
155
|
+
return isModifier(key)
|
|
156
|
+
? actions.keyUp(asCodePoint(key))
|
|
157
|
+
: actions;
|
|
158
|
+
}, keyDownActions);
|
|
159
|
+
|
|
160
|
+
return promised(keyUpActions.perform());
|
|
257
161
|
}
|
|
258
162
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
* Returns the current window handle.
|
|
262
|
-
* Please note that the current handle changes with each browser window you {@link Switch} to.
|
|
263
|
-
*
|
|
264
|
-
* @returns {Promise<string>}
|
|
265
|
-
* A window handle
|
|
266
|
-
*
|
|
267
|
-
* @see {@link get}
|
|
268
|
-
*/
|
|
269
|
-
getCurrentWindowHandle(): Promise<string> {
|
|
270
|
-
return promiseOf(this.browser.getWindowHandle());
|
|
163
|
+
async modalDialog(): Promise<ModalDialog> {
|
|
164
|
+
return new ProtractorModalDialog(this.browser);
|
|
271
165
|
}
|
|
272
166
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
* Please note that while some browsers organise entries of this list in the same order
|
|
278
|
-
* new windows have been spawned, other browsers order it alphabetically.
|
|
279
|
-
* For this reason, you should not make any assumptions about how this list is ordered.
|
|
280
|
-
*
|
|
281
|
-
* @returns {Promise<string[]>}
|
|
282
|
-
* A list of window handles
|
|
283
|
-
*/
|
|
284
|
-
getAllWindowHandles(): Promise<string[]> {
|
|
285
|
-
return promiseOf(this.browser.getAllWindowHandles());
|
|
167
|
+
async frame(bySelector: Selector): Promise<Frame> {
|
|
168
|
+
const locator = this.locate(bySelector);
|
|
169
|
+
|
|
170
|
+
return new ProtractorFrame(this.browser, locator);
|
|
286
171
|
}
|
|
287
172
|
|
|
288
173
|
/**
|
|
289
174
|
* @desc
|
|
290
|
-
*
|
|
175
|
+
* Navigate to the given destination and loads mock modules before Angular.
|
|
176
|
+
* Assumes that the page being loaded uses Angular.
|
|
177
|
+
*
|
|
178
|
+
* @param {string} destination
|
|
179
|
+
* @param {number?} timeoutInMillis
|
|
291
180
|
*
|
|
292
181
|
* @returns {Promise<void>}
|
|
293
182
|
*/
|
|
294
|
-
|
|
295
|
-
return
|
|
183
|
+
get(destination: string, timeoutInMillis?: number): Promise<void> {
|
|
184
|
+
return promised(this.browser.get(destination, timeoutInMillis));
|
|
296
185
|
}
|
|
297
186
|
|
|
298
187
|
/**
|
|
299
188
|
* @desc
|
|
300
|
-
*
|
|
189
|
+
* Returns a {@link Page} representing the currently active top-level browsing context.
|
|
301
190
|
*
|
|
302
|
-
* @
|
|
303
|
-
* @returns {ElementFinder}
|
|
191
|
+
* @returns {Promise<Page>}
|
|
304
192
|
*/
|
|
305
|
-
|
|
306
|
-
|
|
193
|
+
async currentPage(): Promise<Page> {
|
|
194
|
+
|
|
195
|
+
const windowHandle = await this.browser.getWindowHandle();
|
|
196
|
+
|
|
197
|
+
return new ProtractorPage(this.browser, windowHandle);
|
|
307
198
|
}
|
|
308
199
|
|
|
309
200
|
/**
|
|
310
201
|
* @desc
|
|
311
|
-
*
|
|
202
|
+
* Returns an array of {@link Page} objects representing all the available
|
|
203
|
+
* top-level browsing context, e.g. all the open browser tabs.
|
|
312
204
|
*
|
|
313
|
-
* @
|
|
314
|
-
* @returns {ElementArrayFinder}
|
|
205
|
+
* @returns {Promise<Array<Page>>}
|
|
315
206
|
*/
|
|
316
|
-
|
|
317
|
-
|
|
207
|
+
async allPages(): Promise<Array<Page>> {
|
|
208
|
+
const windowHandles = await this.browser.getAllWindowHandles();
|
|
209
|
+
|
|
210
|
+
return windowHandles.map(windowHandle => new ProtractorPage(this.browser, windowHandle));
|
|
318
211
|
}
|
|
319
212
|
|
|
320
213
|
/**
|
|
@@ -343,7 +236,7 @@ export class BrowseTheWeb implements Ability {
|
|
|
343
236
|
* @returns {Promise<boolean>}
|
|
344
237
|
*/
|
|
345
238
|
enableAngularSynchronisation(enable: boolean): Promise<boolean> {
|
|
346
|
-
return
|
|
239
|
+
return promised(this.browser.waitForAngularEnabled(enable));
|
|
347
240
|
}
|
|
348
241
|
|
|
349
242
|
/**
|
|
@@ -380,7 +273,6 @@ export class BrowseTheWeb implements Ability {
|
|
|
380
273
|
* @see https://www.protractortest.org/#/api?view=webdriver.WebDriver.prototype.executeScript
|
|
381
274
|
* @see https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/JavascriptExecutor.html#executeScript-java.lang.String-java.lang.Object...-
|
|
382
275
|
*
|
|
383
|
-
* @param {string} description - useful for debugging
|
|
384
276
|
* @param {string | Function} script
|
|
385
277
|
* @param {any[]} args
|
|
386
278
|
*
|
|
@@ -388,27 +280,34 @@ export class BrowseTheWeb implements Ability {
|
|
|
388
280
|
*
|
|
389
281
|
* @see {@link BrowseTheWeb#getLastScriptExecutionResult}
|
|
390
282
|
*/
|
|
391
|
-
executeScript
|
|
392
|
-
|
|
283
|
+
async executeScript<Result, InnerArguments extends any[]>(
|
|
284
|
+
script: string | ((...parameters: InnerArguments) => Result),
|
|
285
|
+
...args: InnerArguments
|
|
286
|
+
): Promise<Result> {
|
|
287
|
+
const nativeArguments = await Promise.all(args.map(arg => arg instanceof ProtractorPageElement ? arg.nativeElement() : arg)) as InnerArguments;
|
|
288
|
+
|
|
289
|
+
return promised(this.browser.executeScript(script, ...nativeArguments))
|
|
393
290
|
.then(result => {
|
|
394
291
|
this.lastScriptExecutionSummary = new LastScriptExecutionSummary(
|
|
395
292
|
result,
|
|
396
293
|
);
|
|
397
294
|
return result;
|
|
398
|
-
})
|
|
295
|
+
}) as Promise<Result>;
|
|
399
296
|
}
|
|
400
297
|
|
|
401
298
|
/**
|
|
402
299
|
* @desc
|
|
403
|
-
* A simplified version of {@link
|
|
300
|
+
* A simplified version of {@link BrowseTheWebWithProtractor#executeScript} that doesn't affect {@link LastScriptExecution.result()}.
|
|
404
301
|
*
|
|
405
302
|
* @param {Function} fn
|
|
406
303
|
* @param {Parameters<fn>} args
|
|
407
304
|
*
|
|
408
305
|
* @returns {Promise<ReturnType<fn>>}
|
|
409
306
|
*/
|
|
410
|
-
executeFunction<F extends (...args: any[]) => any>(fn: F, ...args: Parameters<F>): Promise<ReturnType<F>> {
|
|
411
|
-
|
|
307
|
+
async executeFunction<F extends (...args: any[]) => any>(fn: F, ...args: Parameters<F>): Promise<ReturnType<F>> {
|
|
308
|
+
const nativeArguments = await Promise.all(args.map(arg => arg instanceof ProtractorPageElement ? arg.nativeElement() : arg)) as Parameters<F>;
|
|
309
|
+
|
|
310
|
+
return promised(this.browser.executeScriptWithDescription(fn, fn.name, ...nativeArguments));
|
|
412
311
|
}
|
|
413
312
|
|
|
414
313
|
/**
|
|
@@ -423,7 +322,7 @@ export class BrowseTheWeb implements Ability {
|
|
|
423
322
|
* Arrays and objects may also be used as script arguments as long as each item adheres
|
|
424
323
|
* to the types previously mentioned.
|
|
425
324
|
*
|
|
426
|
-
* Unlike executing synchronous JavaScript with {@link
|
|
325
|
+
* Unlike executing synchronous JavaScript with {@link BrowseTheWebWithProtractor#executeScript},
|
|
427
326
|
* scripts executed with this function must explicitly signal they are finished by invoking the provided callback.
|
|
428
327
|
*
|
|
429
328
|
* This callback will always be injected into the executed function as the last argument,
|
|
@@ -463,15 +362,19 @@ export class BrowseTheWeb implements Ability {
|
|
|
463
362
|
*
|
|
464
363
|
* @see {@link BrowseTheWeb#getLastScriptExecutionResult}
|
|
465
364
|
*/
|
|
466
|
-
executeAsyncScript
|
|
467
|
-
|
|
365
|
+
async executeAsyncScript<Result, Parameters extends any[]>(
|
|
366
|
+
script: string | ((...args: [...parameters: Parameters, callback: (result: Result) => void]) => void),
|
|
367
|
+
...args: Parameters
|
|
368
|
+
): Promise<Result> {
|
|
369
|
+
const nativeArguments = await Promise.all(args.map(arg => arg instanceof ProtractorPageElement ? arg.nativeElement() : arg)) as Parameters;
|
|
370
|
+
|
|
371
|
+
return promised(this.browser.executeAsyncScript(script, ...nativeArguments))
|
|
468
372
|
.then(result => {
|
|
469
373
|
this.lastScriptExecutionSummary = new LastScriptExecutionSummary(
|
|
470
374
|
result,
|
|
471
375
|
);
|
|
472
376
|
return result;
|
|
473
|
-
})
|
|
474
|
-
// todo: should I wrap this an provide additional diagnostic information? execution time? error handling?
|
|
377
|
+
}) as Promise<Result>;
|
|
475
378
|
}
|
|
476
379
|
|
|
477
380
|
/**
|
|
@@ -487,29 +390,7 @@ export class BrowseTheWeb implements Ability {
|
|
|
487
390
|
* @return {Promise<string>} A promise that will be resolved to a base64-encoded screenshot PNG
|
|
488
391
|
*/
|
|
489
392
|
takeScreenshot(): Promise<string> {
|
|
490
|
-
return
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
/**
|
|
494
|
-
* @desc
|
|
495
|
-
* Returns the title of the current page.
|
|
496
|
-
*
|
|
497
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title
|
|
498
|
-
*
|
|
499
|
-
* @returns {Promise<string>}
|
|
500
|
-
*/
|
|
501
|
-
getTitle(): Promise<string> {
|
|
502
|
-
return promiseOf(this.browser.getTitle());
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
/**
|
|
506
|
-
* @desc
|
|
507
|
-
* Returns the url of the current page.
|
|
508
|
-
*
|
|
509
|
-
* @returns {Promise<string>}
|
|
510
|
-
*/
|
|
511
|
-
getCurrentUrl(): Promise<string> {
|
|
512
|
-
return promiseOf(this.browser.getCurrentUrl());
|
|
393
|
+
return promised(this.browser.takeScreenshot());
|
|
513
394
|
}
|
|
514
395
|
|
|
515
396
|
/**
|
|
@@ -522,8 +403,8 @@ export class BrowseTheWeb implements Ability {
|
|
|
522
403
|
*
|
|
523
404
|
* @returns {Promise<Capabilities>} The actual capabilities of this browser.
|
|
524
405
|
*/
|
|
525
|
-
|
|
526
|
-
return
|
|
406
|
+
capabilities(): Promise<Capabilities> {
|
|
407
|
+
return promised(this.browser.getCapabilities());
|
|
527
408
|
}
|
|
528
409
|
|
|
529
410
|
/**
|
|
@@ -534,7 +415,7 @@ export class BrowseTheWeb implements Ability {
|
|
|
534
415
|
* @returns {Promise<void>}
|
|
535
416
|
*/
|
|
536
417
|
sleep(millis: number): Promise<void> {
|
|
537
|
-
return
|
|
418
|
+
return promised(this.browser.sleep(millis));
|
|
538
419
|
}
|
|
539
420
|
|
|
540
421
|
/**
|
|
@@ -546,22 +427,26 @@ export class BrowseTheWeb implements Ability {
|
|
|
546
427
|
* @returns {Promise<boolean>}
|
|
547
428
|
*/
|
|
548
429
|
wait(condition: () => Promise<boolean>, timeoutInMillis: number): Promise<boolean> {
|
|
549
|
-
return
|
|
430
|
+
return promised(this.browser.wait(condition, timeoutInMillis));
|
|
550
431
|
}
|
|
551
432
|
|
|
552
433
|
/**
|
|
553
434
|
* @desc
|
|
554
|
-
* Returns the last result of calling {@link
|
|
555
|
-
* or {@link
|
|
435
|
+
* Returns the last result of calling {@link BrowseTheWebWithProtractor#executeAsyncScript}
|
|
436
|
+
* or {@link BrowseTheWebWithProtractor#executeScript}
|
|
556
437
|
*
|
|
557
438
|
* @returns {any}
|
|
558
439
|
*/
|
|
559
|
-
|
|
440
|
+
lastScriptExecutionResult(): any {
|
|
560
441
|
if (! this.lastScriptExecutionSummary) {
|
|
561
442
|
throw new LogicError(`Make sure to execute a script before checking on the result`);
|
|
562
443
|
}
|
|
563
444
|
|
|
564
|
-
|
|
445
|
+
// Selenium 3 returns `null` when the script it executed returns `undefined`
|
|
446
|
+
// so we're mapping the result back.
|
|
447
|
+
return this.lastScriptExecutionSummary.result !== null
|
|
448
|
+
? this.lastScriptExecutionSummary.result
|
|
449
|
+
: undefined;
|
|
565
450
|
}
|
|
566
451
|
|
|
567
452
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './BrowseTheWebWithProtractor';
|
package/src/screenplay/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Interaction } from '@serenity-js/core';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { BrowseTheWebWithProtractor } from '../abilities';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @desc
|
|
@@ -53,7 +53,7 @@ export class UseAngular {
|
|
|
53
53
|
*/
|
|
54
54
|
static disableSynchronisation(): Interaction {
|
|
55
55
|
return Interaction.where(`#actor disables synchronisation with Angular`, actor =>
|
|
56
|
-
|
|
56
|
+
(actor.abilityTo(BrowseTheWebWithProtractor) as BrowseTheWebWithProtractor).enableAngularSynchronisation(false).then(() => void 0));
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/**
|
|
@@ -65,6 +65,6 @@ export class UseAngular {
|
|
|
65
65
|
*/
|
|
66
66
|
static enableSynchronisation(): Interaction {
|
|
67
67
|
return Interaction.where(`#actor enables synchronisation with Angular`, actor =>
|
|
68
|
-
|
|
68
|
+
(actor.abilityTo(BrowseTheWebWithProtractor) as BrowseTheWebWithProtractor).enableAngularSynchronisation(true).then(() => void 0));
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -1,20 +1 @@
|
|
|
1
|
-
export * from './Accept';
|
|
2
|
-
export * from './Clear';
|
|
3
|
-
export * from './Click';
|
|
4
|
-
export * from './Close';
|
|
5
|
-
export * from './DeleteCookies';
|
|
6
|
-
export * from './Dismiss';
|
|
7
|
-
export * from './DoubleClick';
|
|
8
|
-
export * from './Enter';
|
|
9
|
-
export * from './ExecuteScript';
|
|
10
|
-
export * from './Hover';
|
|
11
|
-
export * from './Navigate';
|
|
12
|
-
export * from './Press';
|
|
13
|
-
export * from './ResizeBrowserWindow';
|
|
14
|
-
export * from './RightClick';
|
|
15
|
-
export * from './Scroll';
|
|
16
|
-
export * from './Select';
|
|
17
|
-
export * from './Switch';
|
|
18
|
-
export * from './TakeScreenshot';
|
|
19
1
|
export * from './UseAngular';
|
|
20
|
-
export * from './Wait';
|