@serenity-js/protractor 2.32.4 → 3.0.0-rc.2
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 +75 -0
- 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} +52 -160
- package/lib/screenplay/abilities/{BrowseTheWeb.js → BrowseTheWebWithProtractor.js} +169 -218
- 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/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/ProtractorNativeElementRoot.d.ts +5 -0
- package/lib/screenplay/{interactions/EnterBuilder.js → models/ProtractorNativeElementRoot.js} +1 -1
- package/lib/screenplay/models/ProtractorNativeElementRoot.js.map +1 -0
- package/lib/screenplay/models/ProtractorPage.d.ts +24 -0
- package/lib/screenplay/models/ProtractorPage.js +92 -0
- package/lib/screenplay/models/ProtractorPage.js.map +1 -0
- package/lib/screenplay/models/ProtractorPageElement.d.ts +23 -0
- package/lib/screenplay/models/ProtractorPageElement.js +112 -0
- package/lib/screenplay/models/ProtractorPageElement.js.map +1 -0
- package/lib/screenplay/models/ProtractorPageElements.d.ts +16 -0
- package/lib/screenplay/models/ProtractorPageElements.js +62 -0
- package/lib/screenplay/models/ProtractorPageElements.js.map +1 -0
- package/lib/screenplay/models/index.d.ts +6 -0
- package/lib/{expectations → screenplay/models}/index.js +6 -6
- package/lib/screenplay/models/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/promisedWebElement.d.ts +11 -0
- package/lib/screenplay/promisedWebElement.js +27 -0
- package/lib/screenplay/promisedWebElement.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/package.json +19 -21
- package/src/index.ts +0 -2
- package/src/screenplay/abilities/{BrowseTheWeb.ts → BrowseTheWebWithProtractor.ts} +216 -241
- 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/ProtractorModalDialog.ts +49 -0
- package/src/screenplay/models/ProtractorNativeElementRoot.ts +6 -0
- package/src/screenplay/models/ProtractorPage.ts +116 -0
- package/src/screenplay/models/ProtractorPageElement.ts +167 -0
- package/src/screenplay/models/ProtractorPageElements.ts +86 -0
- package/src/screenplay/models/index.ts +7 -0
- package/src/{promiseOf.ts → screenplay/promised.ts} +1 -1
- package/src/screenplay/promisedWebElement.ts +28 -0
- package/src/screenplay/questions/ProtractorParam.ts +29 -38
- package/src/screenplay/questions/index.ts +0 -13
- 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.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 +0 -14
- 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 +0 -14
- 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,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
|
+
BrowseTheWebWithProtractor.as(actor).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
|
+
BrowseTheWebWithProtractor.as(actor).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';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Timestamp } from '@serenity-js/core';
|
|
2
|
+
import { Cookie, CookieData, CookieMissingError } from '@serenity-js/web';
|
|
3
|
+
import { ProtractorBrowser } from 'protractor';
|
|
4
|
+
import { ensure, isDefined } from 'tiny-types';
|
|
5
|
+
|
|
6
|
+
import { promised } from '../promised';
|
|
7
|
+
|
|
8
|
+
export class ProtractorCookie extends Cookie {
|
|
9
|
+
|
|
10
|
+
constructor(private readonly browser: ProtractorBrowser, cookieName: string) {
|
|
11
|
+
super(cookieName);
|
|
12
|
+
ensure('browser', browser, isDefined());
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
delete(): Promise<void> {
|
|
16
|
+
return promised(this.browser.manage().deleteCookie(this.cookieName));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @protected
|
|
21
|
+
*/
|
|
22
|
+
protected async read(): Promise<CookieData> {
|
|
23
|
+
const cookie = await this.browser.manage().getCookie(this.cookieName);
|
|
24
|
+
|
|
25
|
+
if (! cookie) {
|
|
26
|
+
throw new CookieMissingError(`Cookie '${ this.cookieName }' not set`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
name: cookie.name,
|
|
31
|
+
value: cookie.value,
|
|
32
|
+
domain: cookie.domain,
|
|
33
|
+
path: cookie.path,
|
|
34
|
+
expiry: cookie.expiry !== undefined
|
|
35
|
+
? Timestamp.fromTimestampInSeconds(Math.round(cookie.expiry))
|
|
36
|
+
: undefined,
|
|
37
|
+
httpOnly: cookie.httpOnly,
|
|
38
|
+
secure: cookie.secure,
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ModalDialog } from '@serenity-js/web';
|
|
2
|
+
import { ProtractorBrowser } from 'protractor';
|
|
3
|
+
import { error as errors } from 'selenium-webdriver';
|
|
4
|
+
|
|
5
|
+
import { promised } from '../promised';
|
|
6
|
+
|
|
7
|
+
export class ProtractorModalDialog extends ModalDialog {
|
|
8
|
+
|
|
9
|
+
constructor(private readonly browser: ProtractorBrowser) {
|
|
10
|
+
super();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
accept(): Promise<void> {
|
|
14
|
+
return promised(this.browser.switchTo().alert().accept());
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
dismiss(): Promise<void> {
|
|
18
|
+
return promised(this.browser.switchTo().alert().dismiss());
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
text(): Promise<string> {
|
|
22
|
+
return promised(this.browser.switchTo().alert().getText());
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async enterValue(value: string | number | (string | number)[]): Promise<void> {
|
|
26
|
+
const text = [].concat(value).join('');
|
|
27
|
+
await promised(this.browser.switchTo().alert().sendKeys(text));
|
|
28
|
+
await promised(this.browser.switchTo().alert().accept());
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// todo: remove in favour of auto-wait in the above methods
|
|
32
|
+
isPresent(): Promise<boolean> {
|
|
33
|
+
return promised(this.browser.switchTo().alert())
|
|
34
|
+
.then(() => true, error => {
|
|
35
|
+
|
|
36
|
+
// Based on:
|
|
37
|
+
// https://github.com/SeleniumHQ/selenium/blob/941dc9c6b2e2aa4f701c1b72be8de03d4b7e996a/javascript/node/selenium-webdriver/lib/until.js#L107
|
|
38
|
+
return error instanceof Error &&
|
|
39
|
+
! (
|
|
40
|
+
error.name === errors.NoSuchAlertError.name
|
|
41
|
+
// XXX: Workaround for GeckoDriver error `TypeError: can't convert null
|
|
42
|
+
// to object`. For more details, see
|
|
43
|
+
// https://github.com/SeleniumHQ/selenium/pull/2137
|
|
44
|
+
|| (error.name === errors.WebDriverError.name
|
|
45
|
+
&& error.message === `can't convert null to object`)
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Page } from '@serenity-js/web';
|
|
2
|
+
import { ProtractorBrowser } from 'protractor';
|
|
3
|
+
import { URL } from 'url';
|
|
4
|
+
|
|
5
|
+
import { promised } from '../promised';
|
|
6
|
+
|
|
7
|
+
export class ProtractorPage extends Page {
|
|
8
|
+
constructor(
|
|
9
|
+
private readonly browser: ProtractorBrowser,
|
|
10
|
+
handle: string
|
|
11
|
+
) {
|
|
12
|
+
super(handle);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
title(): Promise<string> {
|
|
16
|
+
return this.switchToAndPerform(async browser => {
|
|
17
|
+
return promised(browser.getTitle());
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
name(): Promise<string> {
|
|
22
|
+
return this.switchToAndPerform(async browser => {
|
|
23
|
+
return promised(browser.executeScript('return window.name'));
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
url(): Promise<URL> {
|
|
28
|
+
return this.switchToAndPerform(async browser => {
|
|
29
|
+
return new URL(await promised(browser.getCurrentUrl()));
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async viewportSize(): Promise<{ width: number, height: number }> {
|
|
34
|
+
return this.switchToAndPerform(async browser => {
|
|
35
|
+
const calculatedViewportSize = await promised(browser.executeScript(
|
|
36
|
+
`return {
|
|
37
|
+
width: Math.max(document.documentElement.clientWidth, window.innerWidth || 0),
|
|
38
|
+
height: Math.max(document.documentElement.clientHeight, window.innerHeight || 0)
|
|
39
|
+
};`
|
|
40
|
+
)) as { width: number, height: number };
|
|
41
|
+
|
|
42
|
+
if (calculatedViewportSize.width > 0 && calculatedViewportSize.height > 0) {
|
|
43
|
+
return calculatedViewportSize;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Chrome headless hard-codes window.innerWidth and window.innerHeight to 0
|
|
47
|
+
return promised(browser.manage().window().getSize());
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async setViewportSize(size: { width: number, height: number }): Promise<void> {
|
|
52
|
+
return this.switchToAndPerform(async browser => {
|
|
53
|
+
const desiredWindowSize: { width: number, height: number } = await promised(browser.executeScript(`
|
|
54
|
+
var currentViewportWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0)
|
|
55
|
+
var currentViewportHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0)
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
width: Math.max(window.outerWidth - currentViewportWidth + ${ size.width }, ${ size.width }),
|
|
59
|
+
height: Math.max(window.outerHeight - currentViewportHeight + ${ size.height }, ${ size.height }),
|
|
60
|
+
};
|
|
61
|
+
`));
|
|
62
|
+
|
|
63
|
+
return promised(browser.manage().window().setSize(desiredWindowSize.width, desiredWindowSize.height));
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async close(): Promise<void> {
|
|
68
|
+
return this.switchToAndPerform(browser => promised(browser.close()));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async closeOthers(): Promise<void> {
|
|
72
|
+
const windowHandles = await this.browser.getAllWindowHandles();
|
|
73
|
+
|
|
74
|
+
for (const handle of windowHandles) {
|
|
75
|
+
if (handle !== this.handle) {
|
|
76
|
+
await this.browser.switchTo().window(handle);
|
|
77
|
+
await this.browser.close();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
await this.browser.switchTo().window(this.handle);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async isPresent(): Promise<boolean> {
|
|
85
|
+
const currentPageHandle = await this.browser.getWindowHandle();
|
|
86
|
+
const desiredPageHandle = this.handle;
|
|
87
|
+
|
|
88
|
+
const isOpen = await this.browser.switchTo().window(desiredPageHandle).then(() => true, _error => false);
|
|
89
|
+
|
|
90
|
+
await this.browser.switchTo().window(currentPageHandle);
|
|
91
|
+
|
|
92
|
+
return isOpen;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async switchTo(): Promise<void> {
|
|
96
|
+
await this.browser.switchTo().window(this.handle);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private async switchToAndPerform<T>(action: (browser: ProtractorBrowser) => Promise<T> | T): Promise<T> {
|
|
100
|
+
const originalPageHandle = await this.browser.getWindowHandle();
|
|
101
|
+
const desiredPageHandle = this.handle;
|
|
102
|
+
const shouldSwitch = originalPageHandle !== desiredPageHandle;
|
|
103
|
+
|
|
104
|
+
if (shouldSwitch) {
|
|
105
|
+
await this.browser.switchTo().window(desiredPageHandle);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const result = await action(this.browser);
|
|
109
|
+
|
|
110
|
+
if (shouldSwitch) {
|
|
111
|
+
await this.browser.switchTo().window(originalPageHandle);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { PageElement } from '@serenity-js/web';
|
|
2
|
+
import { ElementFinder, protractor } from 'protractor';
|
|
3
|
+
import { WebElement } from 'selenium-webdriver';
|
|
4
|
+
|
|
5
|
+
import { promised } from '../promised';
|
|
6
|
+
import { promisedWebElement } from '../promisedWebElement';
|
|
7
|
+
import { ProtractorNativeElementRoot } from './ProtractorNativeElementRoot';
|
|
8
|
+
|
|
9
|
+
export class ProtractorPageElement
|
|
10
|
+
extends PageElement<ProtractorNativeElementRoot, ElementFinder>
|
|
11
|
+
{
|
|
12
|
+
constructor(
|
|
13
|
+
context: () => Promise<ProtractorNativeElementRoot> | ProtractorNativeElementRoot,
|
|
14
|
+
locator: (root: ProtractorNativeElementRoot) => Promise<ElementFinder> | ElementFinder
|
|
15
|
+
) {
|
|
16
|
+
super(context, context => {
|
|
17
|
+
return promisedWebElement<ElementFinder>(locator(context));
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
of(parent: ProtractorPageElement): PageElement<ProtractorNativeElementRoot, ElementFinder> {
|
|
22
|
+
return new ProtractorPageElement(() => parent.nativeElement(), this.locator);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async clearValue(): Promise<void> {
|
|
26
|
+
function removeCharactersFrom(elf: ElementFinder, numberOfCharacters: number): PromiseLike<void> {
|
|
27
|
+
return numberOfCharacters === 0
|
|
28
|
+
? Promise.resolve(void 0)
|
|
29
|
+
: elf.sendKeys(
|
|
30
|
+
protractor.Key.END,
|
|
31
|
+
...times(numberOfCharacters, protractor.Key.BACK_SPACE),
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// eslint-disable-next-line unicorn/consistent-function-scoping
|
|
36
|
+
function times(length: number, key: string) {
|
|
37
|
+
return Array.from({ length }).map(() => key);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const currentValue = await this.value();
|
|
41
|
+
|
|
42
|
+
if (currentValue !== null && currentValue !== undefined) {
|
|
43
|
+
const element = await this.nativeElement();
|
|
44
|
+
return removeCharactersFrom(element, currentValue.length);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async click(): Promise<void> {
|
|
49
|
+
const element: ElementFinder = await this.nativeElement();
|
|
50
|
+
|
|
51
|
+
return element.click();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async doubleClick(): Promise<void> {
|
|
55
|
+
const element: ElementFinder = await this.nativeElement();
|
|
56
|
+
const webElement: WebElement = await element.getWebElement();
|
|
57
|
+
|
|
58
|
+
return promised(
|
|
59
|
+
webElement.getDriver().actions()
|
|
60
|
+
.mouseMove(webElement)
|
|
61
|
+
.doubleClick()
|
|
62
|
+
.perform()
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async enterValue(value: string | number | Array<string | number>): Promise<void> {
|
|
67
|
+
const element: ElementFinder = await this.nativeElement();
|
|
68
|
+
|
|
69
|
+
return element.sendKeys(
|
|
70
|
+
[].concat(value).join('')
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async scrollIntoView(): Promise<void> {
|
|
75
|
+
const element: ElementFinder = await this.nativeElement();
|
|
76
|
+
const webElement: WebElement = await element.getWebElement();
|
|
77
|
+
|
|
78
|
+
return promised(
|
|
79
|
+
webElement.getDriver().executeScript('arguments[0].scrollIntoView(true);', webElement)
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async hoverOver(): Promise<void> {
|
|
84
|
+
const element: ElementFinder = await this.nativeElement();
|
|
85
|
+
const webElement: WebElement = await element.getWebElement();
|
|
86
|
+
|
|
87
|
+
return promised(
|
|
88
|
+
webElement.getDriver().actions()
|
|
89
|
+
.mouseMove(webElement)
|
|
90
|
+
.perform()
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async rightClick(): Promise<void> {
|
|
95
|
+
const element: ElementFinder = await this.nativeElement();
|
|
96
|
+
const webElement: WebElement = await element.getWebElement();
|
|
97
|
+
|
|
98
|
+
return promised(
|
|
99
|
+
webElement.getDriver().actions()
|
|
100
|
+
.mouseMove(webElement)
|
|
101
|
+
.click(protractor.Button.RIGHT)
|
|
102
|
+
.perform()
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async attribute(name: string): Promise<string> {
|
|
107
|
+
const element: ElementFinder = await this.nativeElement();
|
|
108
|
+
|
|
109
|
+
return element.getAttribute(name);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async text(): Promise<string> {
|
|
113
|
+
const element: ElementFinder = await this.nativeElement();
|
|
114
|
+
|
|
115
|
+
return element.getText();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async value(): Promise<string> {
|
|
119
|
+
const element: ElementFinder = await this.nativeElement();
|
|
120
|
+
const webElement: WebElement = await element.getWebElement();
|
|
121
|
+
|
|
122
|
+
return promised(webElement.getDriver().executeScript(
|
|
123
|
+
/* istanbul ignore next */
|
|
124
|
+
function getValue(webElement) {
|
|
125
|
+
return webElement.value;
|
|
126
|
+
},
|
|
127
|
+
webElement,
|
|
128
|
+
));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async isActive(): Promise<boolean> {
|
|
132
|
+
const element: ElementFinder = await this.nativeElement();
|
|
133
|
+
const webElement: WebElement = await element.getWebElement();
|
|
134
|
+
|
|
135
|
+
return webElement.getDriver().switchTo().activeElement().then((active: WebElement) =>
|
|
136
|
+
element.equals(active),
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async isClickable(): Promise<boolean> {
|
|
141
|
+
return this.isEnabled();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async isDisplayed(): Promise<boolean> {
|
|
145
|
+
const element: ElementFinder = await this.nativeElement();
|
|
146
|
+
|
|
147
|
+
return element.isDisplayed();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
async isEnabled(): Promise<boolean> {
|
|
151
|
+
const element: ElementFinder = await this.nativeElement();
|
|
152
|
+
|
|
153
|
+
return element.isEnabled();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
async isPresent(): Promise<boolean> {
|
|
157
|
+
const element: ElementFinder = await this.nativeElement();
|
|
158
|
+
|
|
159
|
+
return element.isPresent();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async isSelected(): Promise<boolean> {
|
|
163
|
+
const element: ElementFinder = await this.nativeElement();
|
|
164
|
+
|
|
165
|
+
return element.isSelected();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { LogicError } from '@serenity-js/core';
|
|
2
|
+
import { PageElement, PageElements } from '@serenity-js/web';
|
|
3
|
+
import { ElementArrayFinder, ElementFinder } from 'protractor';
|
|
4
|
+
|
|
5
|
+
import { promisedWebElement } from '../promisedWebElement';
|
|
6
|
+
import { ProtractorNativeElementRoot } from './ProtractorNativeElementRoot';
|
|
7
|
+
import { ProtractorPageElement } from './ProtractorPageElement';
|
|
8
|
+
|
|
9
|
+
export class ProtractorPageElements
|
|
10
|
+
extends PageElements<ProtractorNativeElementRoot, ElementArrayFinder, ElementFinder>
|
|
11
|
+
{
|
|
12
|
+
constructor(
|
|
13
|
+
context: () => Promise<ProtractorNativeElementRoot> | ProtractorNativeElementRoot,
|
|
14
|
+
locator: (root: ProtractorNativeElementRoot) => Promise<ElementArrayFinder> | ElementArrayFinder
|
|
15
|
+
) {
|
|
16
|
+
super(context, async (context: ProtractorNativeElementRoot): Promise<ElementArrayFinder> => {
|
|
17
|
+
return promisedWebElement<ElementArrayFinder>(locator(context));
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
of(parent: PageElement<ProtractorNativeElementRoot, ElementFinder>): ProtractorPageElements {
|
|
22
|
+
return new ProtractorPageElements(() => parent.nativeElement(), this.locator);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async count(): Promise<number> {
|
|
26
|
+
const elements = await this.nativeElementList() as unknown as ElementArrayFinder;
|
|
27
|
+
return elements.count();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async first(): Promise<ProtractorPageElement> {
|
|
31
|
+
const elements = await this.nativeElementList() as unknown as ElementArrayFinder;
|
|
32
|
+
return this.asElement(elements.first());
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async last(): Promise<ProtractorPageElement> {
|
|
36
|
+
const elements = await this.nativeElementList() as unknown as ElementArrayFinder;
|
|
37
|
+
return this.asElement(elements.last());
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async get(index: number): Promise<ProtractorPageElement> {
|
|
41
|
+
const elements = await this.nativeElementList() as unknown as ElementArrayFinder;
|
|
42
|
+
|
|
43
|
+
if (! elements.get(index)) {
|
|
44
|
+
throw new LogicError(`There's no item at index ${ index }`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return this.asElement(elements.get(index));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async map<O>(fn: (element: PageElement, index?: number, elements?: PageElements) => Promise<O> | O): Promise<O[]> {
|
|
51
|
+
const elements = await this.nativeElementList() as unknown as ElementArrayFinder;
|
|
52
|
+
|
|
53
|
+
return elements.map((element?: ElementFinder, i?: number) =>
|
|
54
|
+
fn(new ProtractorPageElement(this.context, _context => element), i, this)
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
filter(fn: (element: PageElement, index?: number) => Promise<boolean> | boolean): PageElements {
|
|
59
|
+
return new ProtractorPageElements(
|
|
60
|
+
this.context,
|
|
61
|
+
async (context: ProtractorNativeElementRoot): Promise<ElementArrayFinder> => {
|
|
62
|
+
const elements = await this.locator(context) as unknown as ElementArrayFinder;
|
|
63
|
+
|
|
64
|
+
const result = elements.filter(async (nativeElement: ElementFinder, index: number) => {
|
|
65
|
+
const element = new ProtractorPageElement(this.context, _context => nativeElement);
|
|
66
|
+
const result = await fn(element, index);
|
|
67
|
+
return result;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return promisedWebElement<ElementArrayFinder>(result);
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async forEach(fn: (element: PageElement, index?: number, elements?: PageElements) => Promise<void> | void): Promise<void> {
|
|
76
|
+
const elements = await this.nativeElementList() as unknown as ElementArrayFinder
|
|
77
|
+
|
|
78
|
+
return elements.each((element: ElementFinder, index: number) => {
|
|
79
|
+
return fn(new ProtractorPageElement(this.context, _context => element), index, this);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private asElement(elementFinder: ElementFinder): PageElement {
|
|
84
|
+
return new ProtractorPageElement(this.context, _context => elementFinder);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @param promiseLike
|
|
8
8
|
* @returns {Promise<T>}
|
|
9
9
|
*/
|
|
10
|
-
export function
|
|
10
|
+
export function promised<T>(promiseLike: PromiseLike<T>): Promise<T> {
|
|
11
11
|
return new Promise((resolve, reject) => {
|
|
12
12
|
promiseLike.then(resolve, reject);
|
|
13
13
|
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { WebElement } from 'protractor';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @desc
|
|
5
|
+
* Wraps Webdriver then-ables into a Node-native promise to allow for correct promise chaining.
|
|
6
|
+
*
|
|
7
|
+
* @private
|
|
8
|
+
*
|
|
9
|
+
* @param promiseLike
|
|
10
|
+
* @returns {Promise<T>}
|
|
11
|
+
*/
|
|
12
|
+
export function promisedWebElement<T extends WebElement>(promiseLike: PromiseLike<T> | T): Promise<T> {
|
|
13
|
+
if (promiseLike instanceof Promise) {
|
|
14
|
+
return promiseLike;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return Promise.resolve(new Proxy(promiseLike, {
|
|
18
|
+
has: (target, property) =>
|
|
19
|
+
property !== 'then',
|
|
20
|
+
ownKeys: (target) =>
|
|
21
|
+
Reflect.ownKeys(target)
|
|
22
|
+
.filter(property => property !== 'then'),
|
|
23
|
+
get: (target, property, receiver) =>
|
|
24
|
+
(property in receiver)
|
|
25
|
+
? target[property]
|
|
26
|
+
: undefined,
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable unicorn/prevent-abbreviations */
|
|
2
|
-
import {
|
|
2
|
+
import { Adapter, Answerable, Question } from '@serenity-js/core';
|
|
3
3
|
import { formatted } from '@serenity-js/core/lib/io';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { BrowseTheWebWithProtractor } from '../abilities';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @desc
|
|
@@ -18,28 +18,40 @@ import { BrowseTheWeb } from '../abilities';
|
|
|
18
18
|
* }
|
|
19
19
|
* }
|
|
20
20
|
* // ...
|
|
21
|
-
*
|
|
21
|
+
* }
|
|
22
22
|
*
|
|
23
23
|
* @example <caption>Overriding configuration parameter via the command line</caption>
|
|
24
24
|
* protractor ./protractor.conf.js --params.login.username="bob@example.org"
|
|
25
25
|
*
|
|
26
|
-
* @example <caption>Using
|
|
26
|
+
* @example <caption>Using as Screenplay Adapter</caption>
|
|
27
27
|
* import { actorCalled } from '@serenity-js/core';
|
|
28
|
-
* import {
|
|
28
|
+
* import { BrowseTheWebWithProtractor, ProtractorParam } from '@serenity-js/protractor';
|
|
29
|
+
* import { Enter } from '@serenity-js/web';
|
|
29
30
|
* import { protractor } from 'protractor';
|
|
30
31
|
*
|
|
31
32
|
* actorCalled('Jane')
|
|
32
|
-
* .whoCan(
|
|
33
|
+
* .whoCan( BrowseTheWebWithProtractor.using(protractor.browser))
|
|
33
34
|
* .attemptsTo(
|
|
34
|
-
* Enter.theValue(ProtractorParam.called('login.username
|
|
35
|
+
* Enter.theValue(ProtractorParam.called('login').username).into(Form.exampleInput),
|
|
35
36
|
* );
|
|
36
37
|
*
|
|
37
|
-
* @
|
|
38
|
+
* @example <caption>Specifying path to param as string</caption>
|
|
39
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
40
|
+
* import { BrowseTheWebWithProtractor, ProtractorParam } from '@serenity-js/protractor';
|
|
41
|
+
* import { Enter } from '@serenity-js/web';
|
|
42
|
+
* import { protractor } from 'protractor';
|
|
43
|
+
*
|
|
44
|
+
* actorCalled('Jane')
|
|
45
|
+
* .whoCan( BrowseTheWebWithProtractor.using(protractor.browser))
|
|
46
|
+
* .attemptsTo(
|
|
47
|
+
* Enter.theValue(ProtractorParam.called('login.username')).into(Form.exampleInput),
|
|
48
|
+
* );
|
|
38
49
|
*
|
|
39
|
-
* @
|
|
50
|
+
* @extends {@serenity-js/core/lib/screenplay~Question<Promise<T>>}
|
|
51
|
+
*g
|
|
52
|
+
* @see {@link BrowseTheWebWithProtractor#param}
|
|
40
53
|
*/
|
|
41
|
-
export class ProtractorParam
|
|
42
|
-
extends Question<Promise<T>>
|
|
54
|
+
export class ProtractorParam
|
|
43
55
|
{
|
|
44
56
|
/**
|
|
45
57
|
* @desc
|
|
@@ -47,33 +59,12 @@ export class ProtractorParam<T = any>
|
|
|
47
59
|
* i.e. `login.username`
|
|
48
60
|
*
|
|
49
61
|
* @param {@serenity-js/core/lib/screenplay~Answerable<string>} name
|
|
50
|
-
* @returns {
|
|
51
|
-
*/
|
|
52
|
-
static called<R>(name: Answerable<string>): ProtractorParam {
|
|
53
|
-
return new ProtractorParam<R>(name);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @param {@serenity-js/core/lib/screenplay~Answerable<string>} name
|
|
58
|
-
*/
|
|
59
|
-
constructor(private readonly name: Answerable<string>) {
|
|
60
|
-
super(formatted `the ${ name } param specified in Protractor config`);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @desc
|
|
65
|
-
* Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
66
|
-
* answer this {@link @serenity-js/core/lib/screenplay~Question}.
|
|
67
|
-
*
|
|
68
|
-
* @param {AnswersQuestions & UsesAbilities} actor
|
|
69
|
-
* @returns {Promise<void>}
|
|
70
|
-
*
|
|
71
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
72
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
73
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
|
|
62
|
+
* @returns {Question<Promise<R>> & Adapter<R>}
|
|
74
63
|
*/
|
|
75
|
-
|
|
76
|
-
return
|
|
77
|
-
|
|
64
|
+
static called<R>(name: Answerable<string>): Question<Promise<R>> & Adapter<R> {
|
|
65
|
+
return Question.about<Promise<R>>(formatted `the ${ name } param specified in Protractor config`, actor => {
|
|
66
|
+
return actor.answer(name)
|
|
67
|
+
.then(name => BrowseTheWebWithProtractor.as(actor).param(name));
|
|
68
|
+
});
|
|
78
69
|
}
|
|
79
70
|
}
|
|
@@ -1,14 +1 @@
|
|
|
1
|
-
export * from './Attribute';
|
|
2
|
-
export * from './Browser';
|
|
3
|
-
export * from './Cookie';
|
|
4
|
-
export * from './CSSClasses';
|
|
5
|
-
export * from './LastScriptExecution';
|
|
6
|
-
export * from './ModalDialog';
|
|
7
|
-
export { Pick } from './Pick';
|
|
8
1
|
export * from './ProtractorParam';
|
|
9
|
-
export * from './Selected';
|
|
10
|
-
export { Target } from './targets';
|
|
11
|
-
export * from './text';
|
|
12
|
-
export * from './Value';
|
|
13
|
-
export * from './Website';
|
|
14
|
-
export * from './Window';
|