@serenity-js/web 3.0.0-rc.9 → 3.0.0
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 +329 -74
- package/README.md +8 -12
- package/lib/errors/BrowserWindowClosedError.d.ts +15 -0
- package/lib/errors/BrowserWindowClosedError.d.ts.map +1 -0
- package/lib/errors/BrowserWindowClosedError.js +21 -0
- package/lib/errors/BrowserWindowClosedError.js.map +1 -0
- package/lib/errors/CookieMissingError.d.ts +11 -0
- package/lib/errors/CookieMissingError.d.ts.map +1 -0
- package/lib/errors/CookieMissingError.js +10 -0
- package/lib/errors/CookieMissingError.js.map +1 -1
- package/lib/errors/ModalDialogObstructsScreenshotError.d.ts +15 -0
- package/lib/errors/ModalDialogObstructsScreenshotError.d.ts.map +1 -0
- package/lib/errors/ModalDialogObstructsScreenshotError.js +21 -0
- package/lib/errors/ModalDialogObstructsScreenshotError.js.map +1 -0
- package/lib/errors/index.d.ts +3 -0
- package/lib/errors/index.d.ts.map +1 -0
- package/lib/errors/index.js +7 -1
- package/lib/errors/index.js.map +1 -1
- package/lib/expectations/index.d.ts +1 -1
- package/lib/expectations/index.d.ts.map +1 -0
- package/lib/expectations/index.js +5 -2
- package/lib/expectations/index.js.map +1 -1
- package/lib/expectations/isActive.d.ts +14 -8
- package/lib/expectations/isActive.d.ts.map +1 -0
- package/lib/expectations/isActive.js +17 -11
- package/lib/expectations/isActive.js.map +1 -1
- package/lib/expectations/isClickable.d.ts +14 -13
- package/lib/expectations/isClickable.d.ts.map +1 -0
- package/lib/expectations/isClickable.js +15 -17
- package/lib/expectations/isClickable.js.map +1 -1
- package/lib/expectations/isEnabled.d.ts +14 -7
- package/lib/expectations/isEnabled.d.ts.map +1 -0
- package/lib/expectations/isEnabled.js +17 -9
- package/lib/expectations/isEnabled.js.map +1 -1
- package/lib/expectations/isSelected.d.ts +14 -7
- package/lib/expectations/isSelected.d.ts.map +1 -0
- package/lib/expectations/isSelected.js +15 -9
- package/lib/expectations/isSelected.js.map +1 -1
- package/lib/expectations/isVisible.d.ts +14 -7
- package/lib/expectations/isVisible.d.ts.map +1 -0
- package/lib/expectations/isVisible.js +17 -9
- package/lib/expectations/isVisible.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +5 -2
- package/lib/index.js.map +1 -1
- package/lib/screenplay/abilities/BrowseTheWeb.d.ts +88 -45
- package/lib/screenplay/abilities/BrowseTheWeb.d.ts.map +1 -0
- package/lib/screenplay/abilities/BrowseTheWeb.js +89 -19
- package/lib/screenplay/abilities/BrowseTheWeb.js.map +1 -1
- package/lib/screenplay/abilities/index.d.ts +1 -1
- package/lib/screenplay/abilities/index.d.ts.map +1 -0
- package/lib/screenplay/abilities/index.js +5 -2
- package/lib/screenplay/abilities/index.js.map +1 -1
- package/lib/screenplay/index.d.ts +1 -0
- package/lib/screenplay/index.d.ts.map +1 -0
- package/lib/screenplay/index.js +5 -1
- package/lib/screenplay/index.js.map +1 -1
- package/lib/screenplay/interactions/Clear.d.ts +50 -55
- package/lib/screenplay/interactions/Clear.d.ts.map +1 -0
- package/lib/screenplay/interactions/Clear.js +70 -63
- package/lib/screenplay/interactions/Clear.js.map +1 -1
- package/lib/screenplay/interactions/Click.d.ts +41 -50
- package/lib/screenplay/interactions/Click.d.ts.map +1 -0
- package/lib/screenplay/interactions/Click.js +45 -55
- package/lib/screenplay/interactions/Click.js.map +1 -1
- package/lib/screenplay/interactions/DoubleClick.d.ts +64 -67
- package/lib/screenplay/interactions/DoubleClick.d.ts.map +1 -0
- package/lib/screenplay/interactions/DoubleClick.js +68 -72
- package/lib/screenplay/interactions/DoubleClick.js.map +1 -1
- package/lib/screenplay/interactions/Enter.d.ts +42 -51
- package/lib/screenplay/interactions/Enter.d.ts.map +1 -0
- package/lib/screenplay/interactions/Enter.js +42 -52
- package/lib/screenplay/interactions/Enter.js.map +1 -1
- package/lib/screenplay/interactions/ExecuteScript.d.ts +144 -148
- package/lib/screenplay/interactions/ExecuteScript.d.ts.map +1 -0
- package/lib/screenplay/interactions/ExecuteScript.js +163 -185
- package/lib/screenplay/interactions/ExecuteScript.js.map +1 -1
- package/lib/screenplay/interactions/Hover.d.ts +40 -50
- package/lib/screenplay/interactions/Hover.d.ts.map +1 -0
- package/lib/screenplay/interactions/Hover.js +44 -55
- package/lib/screenplay/interactions/Hover.js.map +1 -1
- package/lib/screenplay/interactions/Navigate.d.ts +106 -113
- package/lib/screenplay/interactions/Navigate.d.ts.map +1 -0
- package/lib/screenplay/interactions/Navigate.js +124 -146
- package/lib/screenplay/interactions/Navigate.js.map +1 -1
- package/lib/screenplay/interactions/PageElementInteraction.d.ts +12 -28
- package/lib/screenplay/interactions/PageElementInteraction.d.ts.map +1 -0
- package/lib/screenplay/interactions/PageElementInteraction.js +12 -33
- package/lib/screenplay/interactions/PageElementInteraction.js.map +1 -1
- package/lib/screenplay/interactions/Press.d.ts +61 -55
- package/lib/screenplay/interactions/Press.d.ts.map +1 -0
- package/lib/screenplay/interactions/Press.js +83 -72
- package/lib/screenplay/interactions/Press.js.map +1 -1
- package/lib/screenplay/interactions/RightClick.d.ts +59 -65
- package/lib/screenplay/interactions/RightClick.d.ts.map +1 -0
- package/lib/screenplay/interactions/RightClick.js +63 -70
- package/lib/screenplay/interactions/RightClick.js.map +1 -1
- package/lib/screenplay/interactions/Scroll.d.ts +46 -64
- package/lib/screenplay/interactions/Scroll.d.ts.map +1 -0
- package/lib/screenplay/interactions/Scroll.js +49 -71
- package/lib/screenplay/interactions/Scroll.js.map +1 -1
- package/lib/screenplay/interactions/Select.d.ts +217 -193
- package/lib/screenplay/interactions/Select.d.ts.map +1 -0
- package/lib/screenplay/interactions/Select.js +218 -245
- package/lib/screenplay/interactions/Select.js.map +1 -1
- package/lib/screenplay/interactions/Switch.d.ts +105 -128
- package/lib/screenplay/interactions/Switch.d.ts.map +1 -0
- package/lib/screenplay/interactions/Switch.js +121 -172
- package/lib/screenplay/interactions/Switch.js.map +1 -1
- package/lib/screenplay/interactions/TakeScreenshot.d.ts +28 -50
- package/lib/screenplay/interactions/TakeScreenshot.d.ts.map +1 -0
- package/lib/screenplay/interactions/TakeScreenshot.js +32 -57
- package/lib/screenplay/interactions/TakeScreenshot.js.map +1 -1
- package/lib/screenplay/interactions/index.d.ts +2 -3
- package/lib/screenplay/interactions/index.d.ts.map +1 -0
- package/lib/screenplay/interactions/index.js +6 -4
- package/lib/screenplay/interactions/index.js.map +1 -1
- package/lib/screenplay/models/BrowserCapabilities.d.ts +24 -0
- package/lib/screenplay/models/BrowserCapabilities.d.ts.map +1 -0
- package/lib/screenplay/models/BrowserCapabilities.js.map +1 -0
- package/lib/screenplay/models/BrowsingSession.d.ts +69 -0
- package/lib/screenplay/models/BrowsingSession.d.ts.map +1 -0
- package/lib/screenplay/models/BrowsingSession.js +101 -0
- package/lib/screenplay/models/BrowsingSession.js.map +1 -0
- package/lib/screenplay/models/Cookie.d.ts +104 -64
- package/lib/screenplay/models/Cookie.d.ts.map +1 -0
- package/lib/screenplay/models/Cookie.js +110 -59
- package/lib/screenplay/models/Cookie.js.map +1 -1
- package/lib/screenplay/models/CookieData.d.ts +20 -58
- package/lib/screenplay/models/CookieData.d.ts.map +1 -0
- package/lib/{input → screenplay/models}/Key.d.ts +13 -9
- package/lib/screenplay/models/Key.d.ts.map +1 -0
- package/lib/{input → screenplay/models}/Key.js +16 -13
- package/lib/screenplay/models/Key.js.map +1 -0
- package/lib/screenplay/models/Locator.d.ts +29 -8
- package/lib/screenplay/models/Locator.d.ts.map +1 -0
- package/lib/screenplay/models/Locator.js +53 -7
- package/lib/screenplay/models/Locator.js.map +1 -1
- package/lib/screenplay/models/Page.d.ts +398 -36
- package/lib/screenplay/models/Page.d.ts.map +1 -0
- package/lib/screenplay/models/Page.js +209 -4
- package/lib/screenplay/models/Page.js.map +1 -1
- package/lib/screenplay/models/PageElement.d.ts +77 -5
- package/lib/screenplay/models/PageElement.d.ts.map +1 -0
- package/lib/screenplay/models/PageElement.js +29 -7
- package/lib/screenplay/models/PageElement.js.map +1 -1
- package/lib/screenplay/models/PageElements.d.ts +16 -3
- package/lib/screenplay/models/PageElements.d.ts.map +1 -0
- package/lib/screenplay/models/PageElements.js +21 -8
- package/lib/screenplay/models/PageElements.js.map +1 -1
- package/lib/screenplay/models/RootLocator.d.ts +25 -0
- package/lib/screenplay/models/RootLocator.d.ts.map +1 -0
- package/lib/screenplay/models/RootLocator.js +52 -0
- package/lib/screenplay/models/RootLocator.js.map +1 -0
- package/lib/screenplay/models/SelectOption.d.ts +25 -0
- package/lib/screenplay/models/SelectOption.d.ts.map +1 -0
- package/lib/screenplay/models/SelectOption.js +37 -0
- package/lib/screenplay/models/SelectOption.js.map +1 -0
- package/lib/screenplay/models/Switchable.d.ts +23 -0
- package/lib/screenplay/models/Switchable.d.ts.map +1 -0
- package/lib/screenplay/{interactions/WaitBuilder.js → models/Switchable.js} +1 -1
- package/lib/screenplay/models/Switchable.js.map +1 -0
- package/lib/screenplay/models/SwitchableOrigin.d.ts +18 -0
- package/lib/screenplay/models/SwitchableOrigin.d.ts.map +1 -0
- package/lib/screenplay/{interactions/EnterBuilder.js → models/SwitchableOrigin.js} +1 -1
- package/lib/screenplay/models/SwitchableOrigin.js.map +1 -0
- package/lib/screenplay/models/dialogs/AbsentModalDialog.d.ts +15 -0
- package/lib/screenplay/models/dialogs/AbsentModalDialog.d.ts.map +1 -0
- package/lib/screenplay/models/dialogs/AbsentModalDialog.js +24 -0
- package/lib/screenplay/models/dialogs/AbsentModalDialog.js.map +1 -0
- package/lib/screenplay/models/dialogs/AcceptedModalDialog.d.ts +17 -0
- package/lib/screenplay/models/dialogs/AcceptedModalDialog.d.ts.map +1 -0
- package/lib/screenplay/models/dialogs/AcceptedModalDialog.js +29 -0
- package/lib/screenplay/models/dialogs/AcceptedModalDialog.js.map +1 -0
- package/lib/screenplay/models/dialogs/DismissedModalDialog.d.ts +17 -0
- package/lib/screenplay/models/dialogs/DismissedModalDialog.d.ts.map +1 -0
- package/lib/screenplay/models/dialogs/DismissedModalDialog.js +29 -0
- package/lib/screenplay/models/dialogs/DismissedModalDialog.js.map +1 -0
- package/lib/screenplay/models/dialogs/ModalDialog.d.ts +168 -0
- package/lib/screenplay/models/dialogs/ModalDialog.d.ts.map +1 -0
- package/lib/screenplay/models/dialogs/ModalDialog.js +174 -0
- package/lib/screenplay/models/dialogs/ModalDialog.js.map +1 -0
- package/lib/screenplay/models/dialogs/ModalDialogHandler.d.ts +38 -0
- package/lib/screenplay/models/dialogs/ModalDialogHandler.d.ts.map +1 -0
- package/lib/screenplay/models/dialogs/ModalDialogHandler.js +30 -0
- package/lib/screenplay/models/dialogs/ModalDialogHandler.js.map +1 -0
- package/lib/screenplay/models/dialogs/index.d.ts +6 -0
- package/lib/screenplay/models/dialogs/index.d.ts.map +1 -0
- package/lib/screenplay/models/dialogs/index.js +22 -0
- package/lib/screenplay/models/dialogs/index.js.map +1 -0
- package/lib/screenplay/models/index.d.ts +9 -1
- package/lib/screenplay/models/index.d.ts.map +1 -0
- package/lib/screenplay/models/index.js +13 -2
- package/lib/screenplay/models/index.js.map +1 -1
- package/lib/screenplay/models/selectors/By.d.ts +38 -0
- package/lib/screenplay/models/selectors/By.d.ts.map +1 -0
- package/lib/screenplay/models/selectors/By.js +43 -0
- package/lib/screenplay/models/selectors/By.js.map +1 -1
- package/lib/screenplay/models/selectors/ByCss.d.ts +8 -0
- package/lib/screenplay/models/selectors/ByCss.d.ts.map +1 -0
- package/lib/screenplay/models/selectors/ByCss.js +7 -0
- package/lib/screenplay/models/selectors/ByCss.js.map +1 -1
- package/lib/screenplay/models/selectors/ByCssContainingText.d.ts +9 -0
- package/lib/screenplay/models/selectors/ByCssContainingText.d.ts.map +1 -0
- package/lib/screenplay/models/selectors/ByCssContainingText.js +8 -0
- package/lib/screenplay/models/selectors/ByCssContainingText.js.map +1 -1
- package/lib/screenplay/models/selectors/ByDeepCss.d.ts +14 -0
- package/lib/screenplay/models/selectors/ByDeepCss.d.ts.map +1 -0
- package/lib/screenplay/models/selectors/ByDeepCss.js +20 -0
- package/lib/screenplay/models/selectors/ByDeepCss.js.map +1 -0
- package/lib/screenplay/models/selectors/ById.d.ts +8 -0
- package/lib/screenplay/models/selectors/ById.d.ts.map +1 -0
- package/lib/screenplay/models/selectors/ById.js +7 -0
- package/lib/screenplay/models/selectors/ById.js.map +1 -1
- package/lib/screenplay/models/selectors/ByTagName.d.ts +8 -0
- package/lib/screenplay/models/selectors/ByTagName.d.ts.map +1 -0
- package/lib/screenplay/models/selectors/ByTagName.js +7 -0
- package/lib/screenplay/models/selectors/ByTagName.js.map +1 -1
- package/lib/screenplay/models/selectors/ByXPath.d.ts +8 -0
- package/lib/screenplay/models/selectors/ByXPath.d.ts.map +1 -0
- package/lib/screenplay/models/selectors/ByXPath.js +7 -0
- package/lib/screenplay/models/selectors/ByXPath.js.map +1 -1
- package/lib/screenplay/models/selectors/Selector.d.ts +6 -0
- package/lib/screenplay/models/selectors/Selector.d.ts.map +1 -0
- package/lib/screenplay/models/selectors/Selector.js +6 -1
- package/lib/screenplay/models/selectors/Selector.js.map +1 -1
- package/lib/screenplay/models/selectors/index.d.ts +2 -0
- package/lib/screenplay/models/selectors/index.d.ts.map +1 -0
- package/lib/screenplay/models/selectors/index.js +6 -1
- package/lib/screenplay/models/selectors/index.js.map +1 -1
- package/lib/screenplay/questions/Attribute.d.ts +115 -67
- package/lib/screenplay/questions/Attribute.d.ts.map +1 -0
- package/lib/screenplay/questions/Attribute.js +128 -74
- package/lib/screenplay/questions/Attribute.js.map +1 -1
- package/lib/screenplay/questions/CssClasses.d.ts +124 -79
- package/lib/screenplay/questions/CssClasses.d.ts.map +1 -0
- package/lib/screenplay/questions/CssClasses.js +132 -83
- package/lib/screenplay/questions/CssClasses.js.map +1 -1
- package/lib/screenplay/questions/LastScriptExecution.d.ts +42 -6
- package/lib/screenplay/questions/LastScriptExecution.d.ts.map +1 -0
- package/lib/screenplay/questions/LastScriptExecution.js +45 -7
- package/lib/screenplay/questions/LastScriptExecution.js.map +1 -1
- package/lib/screenplay/questions/Selected.d.ts +202 -171
- package/lib/screenplay/questions/Selected.d.ts.map +1 -0
- package/lib/screenplay/questions/Selected.js +225 -186
- package/lib/screenplay/questions/Selected.js.map +1 -1
- package/lib/screenplay/questions/Text.d.ts +101 -82
- package/lib/screenplay/questions/Text.d.ts.map +1 -0
- package/lib/screenplay/questions/Text.js +143 -92
- package/lib/screenplay/questions/Text.js.map +1 -1
- package/lib/screenplay/questions/Value.d.ts +77 -44
- package/lib/screenplay/questions/Value.d.ts.map +1 -0
- package/lib/screenplay/questions/Value.js +84 -47
- package/lib/screenplay/questions/Value.js.map +1 -1
- package/lib/screenplay/questions/index.d.ts +1 -0
- package/lib/screenplay/questions/index.d.ts.map +1 -0
- package/lib/screenplay/questions/index.js +5 -1
- package/lib/screenplay/questions/index.js.map +1 -1
- package/lib/scripts/index.d.ts +2 -0
- package/lib/scripts/index.d.ts.map +1 -0
- package/lib/{input → scripts}/index.js +6 -2
- package/lib/scripts/index.js.map +1 -0
- package/lib/scripts/isVisible.d.ts +2 -0
- package/lib/scripts/isVisible.d.ts.map +1 -0
- package/lib/scripts/isVisible.js +96 -0
- package/lib/scripts/isVisible.js.map +1 -0
- package/lib/stage/crew/index.d.ts +1 -0
- package/lib/stage/crew/index.d.ts.map +1 -0
- package/lib/stage/crew/index.js +5 -1
- package/lib/stage/crew/index.js.map +1 -1
- package/lib/stage/crew/photographer/Photographer.d.ts +126 -39
- package/lib/stage/crew/photographer/Photographer.d.ts.map +1 -0
- package/lib/stage/crew/photographer/Photographer.js +161 -42
- package/lib/stage/crew/photographer/Photographer.js.map +1 -1
- package/lib/stage/crew/photographer/index.d.ts +1 -0
- package/lib/stage/crew/photographer/index.d.ts.map +1 -0
- package/lib/stage/crew/photographer/index.js +5 -1
- package/lib/stage/crew/photographer/index.js.map +1 -1
- package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.d.ts +13 -12
- package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.d.ts.map +1 -0
- package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.js +22 -33
- package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.js.map +1 -1
- package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.d.ts +8 -8
- package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.d.ts.map +1 -0
- package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.js +7 -8
- package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.js.map +1 -1
- package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.d.ts +8 -7
- package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.d.ts.map +1 -0
- package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.js +7 -7
- package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.d.ts +8 -8
- package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.d.ts.map +1 -0
- package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.js +7 -8
- package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.js.map +1 -1
- package/lib/stage/crew/photographer/strategies/index.d.ts +1 -0
- package/lib/stage/crew/photographer/strategies/index.d.ts.map +1 -0
- package/lib/stage/crew/photographer/strategies/index.js +5 -1
- package/lib/stage/crew/photographer/strategies/index.js.map +1 -1
- package/lib/stage/index.d.ts +1 -0
- package/lib/stage/index.d.ts.map +1 -0
- package/lib/stage/index.js +5 -1
- package/lib/stage/index.js.map +1 -1
- package/package.json +20 -43
- package/src/errors/BrowserWindowClosedError.ts +17 -0
- package/src/errors/CookieMissingError.ts +10 -0
- package/src/errors/ModalDialogObstructsScreenshotError.ts +17 -0
- package/src/errors/index.ts +2 -0
- package/src/expectations/index.ts +0 -1
- package/src/expectations/isActive.ts +23 -12
- package/src/expectations/isClickable.ts +22 -21
- package/src/expectations/isEnabled.ts +23 -9
- package/src/expectations/isSelected.ts +20 -10
- package/src/expectations/isVisible.ts +23 -9
- package/src/index.ts +0 -1
- package/src/screenplay/abilities/BrowseTheWeb.ts +95 -87
- package/src/screenplay/abilities/index.ts +0 -1
- package/src/screenplay/interactions/Clear.ts +75 -63
- package/src/screenplay/interactions/Click.ts +43 -54
- package/src/screenplay/interactions/DoubleClick.ts +66 -71
- package/src/screenplay/interactions/Enter.ts +41 -53
- package/src/screenplay/interactions/ExecuteScript.ts +207 -220
- package/src/screenplay/interactions/Hover.ts +42 -54
- package/src/screenplay/interactions/Navigate.ts +129 -156
- package/src/screenplay/interactions/PageElementInteraction.ts +14 -34
- package/src/screenplay/interactions/Press.ts +78 -69
- package/src/screenplay/interactions/RightClick.ts +61 -69
- package/src/screenplay/interactions/Scroll.ts +48 -71
- package/src/screenplay/interactions/Select.ts +229 -269
- package/src/screenplay/interactions/Switch.ts +123 -179
- package/src/screenplay/interactions/TakeScreenshot.ts +31 -57
- package/src/screenplay/interactions/index.ts +1 -3
- package/src/screenplay/models/BrowserCapabilities.ts +26 -0
- package/src/screenplay/models/BrowsingSession.ts +115 -0
- package/src/screenplay/models/Cookie.ts +115 -73
- package/src/screenplay/models/CookieData.ts +20 -58
- package/src/{input → screenplay/models}/Key.ts +12 -9
- package/src/screenplay/models/Locator.ts +43 -9
- package/src/screenplay/models/Page.ts +438 -37
- package/src/screenplay/models/PageElement.ts +92 -12
- package/src/screenplay/models/PageElements.ts +23 -9
- package/src/screenplay/models/RootLocator.ts +30 -0
- package/src/screenplay/models/SelectOption.ts +38 -0
- package/src/screenplay/models/Switchable.ts +24 -0
- package/src/screenplay/models/SwitchableOrigin.ts +18 -0
- package/src/screenplay/models/dialogs/AbsentModalDialog.ts +22 -0
- package/src/screenplay/models/dialogs/AcceptedModalDialog.ts +27 -0
- package/src/screenplay/models/dialogs/DismissedModalDialog.ts +27 -0
- package/src/screenplay/models/dialogs/ModalDialog.ts +200 -0
- package/src/screenplay/models/dialogs/ModalDialogHandler.ts +50 -0
- package/src/screenplay/models/dialogs/index.ts +5 -0
- package/src/screenplay/models/index.ts +8 -1
- package/src/screenplay/models/selectors/By.ts +45 -0
- package/src/screenplay/models/selectors/ByCss.ts +7 -0
- package/src/screenplay/models/selectors/ByCssContainingText.ts +8 -0
- package/src/screenplay/models/selectors/ByDeepCss.ts +15 -0
- package/src/screenplay/models/selectors/ById.ts +7 -0
- package/src/screenplay/models/selectors/ByTagName.ts +7 -0
- package/src/screenplay/models/selectors/ByXPath.ts +7 -0
- package/src/screenplay/models/selectors/Selector.ts +6 -1
- package/src/screenplay/models/selectors/index.ts +1 -0
- package/src/screenplay/questions/Attribute.ts +137 -76
- package/src/screenplay/questions/CssClasses.ts +135 -83
- package/src/screenplay/questions/LastScriptExecution.ts +45 -8
- package/src/screenplay/questions/Selected.ts +237 -191
- package/src/screenplay/questions/Text.ts +161 -96
- package/src/screenplay/questions/Value.ts +88 -48
- package/src/scripts/index.ts +1 -0
- package/src/scripts/isVisible.ts +113 -0
- package/src/stage/crew/photographer/Photographer.ts +142 -41
- package/src/stage/crew/photographer/strategies/PhotoTakingStrategy.ts +27 -42
- package/src/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.ts +7 -8
- package/src/stage/crew/photographer/strategies/TakePhotosOfFailures.ts +7 -7
- package/src/stage/crew/photographer/strategies/TakePhotosOfInteractions.ts +7 -8
- package/tsconfig.build.json +14 -0
- package/lib/expectations/ElementExpectation.d.ts +0 -83
- package/lib/expectations/ElementExpectation.js +0 -102
- package/lib/expectations/ElementExpectation.js.map +0 -1
- package/lib/input/Key.js.map +0 -1
- package/lib/input/index.d.ts +0 -1
- package/lib/input/index.js.map +0 -1
- package/lib/screenplay/abilities/BrowserCapabilities.d.ts +0 -5
- package/lib/screenplay/abilities/BrowserCapabilities.js.map +0 -1
- package/lib/screenplay/interactions/EnterBuilder.d.ts +0 -25
- package/lib/screenplay/interactions/EnterBuilder.js.map +0 -1
- package/lib/screenplay/interactions/PressBuilder.d.ts +0 -26
- package/lib/screenplay/interactions/PressBuilder.js +0 -3
- package/lib/screenplay/interactions/PressBuilder.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/Wait.d.ts +0 -143
- package/lib/screenplay/interactions/Wait.js +0 -238
- package/lib/screenplay/interactions/Wait.js.map +0 -1
- package/lib/screenplay/interactions/WaitBuilder.d.ts +0 -32
- package/lib/screenplay/interactions/WaitBuilder.js.map +0 -1
- package/lib/screenplay/models/ModalDialog.d.ts +0 -9
- package/lib/screenplay/models/ModalDialog.js +0 -14
- package/lib/screenplay/models/ModalDialog.js.map +0 -1
- package/lib/screenplay/questions/ElementQuestion.d.ts +0 -33
- package/lib/screenplay/questions/ElementQuestion.js +0 -53
- package/lib/screenplay/questions/ElementQuestion.js.map +0 -1
- package/src/expectations/ElementExpectation.ts +0 -108
- package/src/input/index.ts +0 -1
- package/src/screenplay/abilities/BrowserCapabilities.ts +0 -5
- package/src/screenplay/interactions/EnterBuilder.ts +0 -28
- package/src/screenplay/interactions/PressBuilder.ts +0 -29
- package/src/screenplay/interactions/SelectBuilder.ts +0 -36
- package/src/screenplay/interactions/Wait.ts +0 -260
- package/src/screenplay/interactions/WaitBuilder.ts +0 -34
- package/src/screenplay/models/ModalDialog.ts +0 -19
- package/src/screenplay/questions/ElementQuestion.ts +0 -58
- package/tsconfig.eslint.json +0 -10
- /package/lib/screenplay/{abilities → models}/BrowserCapabilities.js +0 -0
|
@@ -1,15 +1,163 @@
|
|
|
1
1
|
import { Expectation, ExpectationMet, ExpectationOutcome, LogicError, Optional, Question, QuestionAdapter } from '@serenity-js/core';
|
|
2
|
+
import { CorrelationId } from '@serenity-js/core/lib/model';
|
|
3
|
+
import { ensure, isDefined } from 'tiny-types';
|
|
2
4
|
import { URL } from 'url';
|
|
3
5
|
|
|
4
6
|
import { BrowseTheWeb } from '../abilities';
|
|
7
|
+
import { BrowsingSession } from './BrowsingSession';
|
|
8
|
+
import { Cookie } from './Cookie';
|
|
9
|
+
import { CookieData } from './CookieData';
|
|
10
|
+
import { ModalDialogHandler } from './dialogs';
|
|
11
|
+
import { Key } from './Key';
|
|
12
|
+
import { PageElement } from './PageElement';
|
|
13
|
+
import { PageElements } from './PageElements';
|
|
14
|
+
import { RootLocator } from './RootLocator';
|
|
15
|
+
import { Selector } from './selectors';
|
|
16
|
+
import { Switchable } from './Switchable';
|
|
17
|
+
import { SwitchableOrigin } from './SwitchableOrigin';
|
|
5
18
|
|
|
6
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Serenity/JS Screenplay Pattern-style model that enables interactions with a Web page
|
|
21
|
+
* rendered in a Web browser tab.
|
|
22
|
+
*
|
|
23
|
+
* ## Referring to the current page
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* import { Ensure, endsWith } from '@serenity-js/assertions'
|
|
27
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
28
|
+
* import { Navigate, Page } from '@serenity-js/web'
|
|
29
|
+
*
|
|
30
|
+
* await actorCalled('Serena').attemptsTo(
|
|
31
|
+
* Navigate.to('https://serenity-js.org'),
|
|
32
|
+
* Ensure.that(Page.current().title(), endsWith('Serenity/JS')),
|
|
33
|
+
* )
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* ## Switching to another open page
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { Ensure, equals, includes, startsWith } from '@serenity-js/assertions'
|
|
40
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
41
|
+
* import { Navigate, Page, Switch, Text } from '@serenity-js/web'
|
|
42
|
+
*
|
|
43
|
+
* const Navigation = {
|
|
44
|
+
* linkTo = (name: Answerable<string>) =>
|
|
45
|
+
* PageElements.located(By.css('nav a'))
|
|
46
|
+
* .where(Text, includes(name))
|
|
47
|
+
* .first()
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* await actorCalled('Serena').attemptsTo(
|
|
51
|
+
* Navigate.to('https://serenity-js.org'),
|
|
52
|
+
* Click.on(Navigation.linkTo('GitHub')),
|
|
53
|
+
*
|
|
54
|
+
* Switch.to(Page.whichUrl(startsWith('https://github.com')))
|
|
55
|
+
*
|
|
56
|
+
* Ensure.that(
|
|
57
|
+
* Page.current().url().href,
|
|
58
|
+
* equals('https://github.com/serenity-js/serenity-js')
|
|
59
|
+
* ),
|
|
60
|
+
* )
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* ## Retrieving information about another open page
|
|
64
|
+
*
|
|
65
|
+
* You can retrieve information about another open page without having to explicitly switch to it:
|
|
66
|
+
*
|
|
67
|
+
* ```ts
|
|
68
|
+
* import { Ensure, equals, includes, startsWith } from '@serenity-js/assertions'
|
|
69
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
70
|
+
* import { Navigate, Page, Text } from '@serenity-js/web'
|
|
71
|
+
*
|
|
72
|
+
* const Navigation = {
|
|
73
|
+
* linkTo = (name: Answerable<string>) =>
|
|
74
|
+
* PageElements.located(By.css('nav a'))
|
|
75
|
+
* .where(Text, includes(name))
|
|
76
|
+
* .first()
|
|
77
|
+
* }
|
|
78
|
+
*
|
|
79
|
+
* await actorCalled('Serena').attemptsTo(
|
|
80
|
+
* Navigate.to('https://serenity-js.org'),
|
|
81
|
+
* Click.on(Navigation.linkTo('GitHub')),
|
|
82
|
+
* Ensure.that(
|
|
83
|
+
* Page.whichUrl(startsWith('https://github.com')).url().href,
|
|
84
|
+
* equals('https://github.com/serenity-js/serenity-js')
|
|
85
|
+
* ),
|
|
86
|
+
* )
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* ## Performing activities in the context of another page
|
|
90
|
+
*
|
|
91
|
+
* ```ts
|
|
92
|
+
* import { Ensure, equals, includes, startsWith } from '@serenity-js/assertions'
|
|
93
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
94
|
+
* import { Navigate, Page, Text } from '@serenity-js/web'
|
|
95
|
+
*
|
|
96
|
+
* const Navigation = {
|
|
97
|
+
* linkTo = (name: Answerable<string>) =>
|
|
98
|
+
* PageElements.located(By.css('nav a'))
|
|
99
|
+
* .where(Text, includes(name))
|
|
100
|
+
* .first()
|
|
101
|
+
* }
|
|
102
|
+
*
|
|
103
|
+
* await actorCalled('Serena').attemptsTo(
|
|
104
|
+
*
|
|
105
|
+
* // Serenity/JS GitHub repository opens in a new browser tab
|
|
106
|
+
* Navigate.to('https://serenity-js.org'),
|
|
107
|
+
* Click.on(Navigation.linkTo('GitHub')),
|
|
108
|
+
*
|
|
109
|
+
* // Switch to the newly opened page and perform an assertion
|
|
110
|
+
* Switch.to(Page.whichUrl(startsWith('https://github.com')))
|
|
111
|
+
* .and(
|
|
112
|
+
* Ensure.that(
|
|
113
|
+
* Page.current().url().href,
|
|
114
|
+
* equals('https://github.com/serenity-js/serenity-js')
|
|
115
|
+
* )
|
|
116
|
+
* ),
|
|
117
|
+
* // Automatically switch back to the original page
|
|
118
|
+
*
|
|
119
|
+
* Ensure.that(Page.current().url().href, equals('https://serenity-js.org'),
|
|
120
|
+
* )
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* ## Learn more
|
|
124
|
+
*
|
|
125
|
+
* - {@apilink BrowseTheWeb}
|
|
126
|
+
* - {@apilink PageElement}
|
|
127
|
+
* - {@apilink Optional}
|
|
128
|
+
* - {@apilink Switchable}
|
|
129
|
+
*
|
|
130
|
+
* @group Models
|
|
131
|
+
*/
|
|
132
|
+
export abstract class Page<Native_Element_Type = any> implements Optional, Switchable {
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Creates a {@apilink QuestionAdapter} representing the currently active {@apilink Page}.
|
|
136
|
+
*/
|
|
7
137
|
static current(): QuestionAdapter<Page> {
|
|
8
138
|
return Question.about<Page>('current page', actor => {
|
|
9
139
|
return BrowseTheWeb.as(actor).currentPage();
|
|
10
140
|
});
|
|
11
141
|
}
|
|
12
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Creates a {@apilink QuestionAdapter} that resolves to a {@apilink Page} which {@apilink Page.name}
|
|
145
|
+
* meets the {@apilink Expectation|`expectation`}.
|
|
146
|
+
*
|
|
147
|
+
* #### Switching to a page with the desired name
|
|
148
|
+
*
|
|
149
|
+
* ```ts
|
|
150
|
+
* import { includes } from '@serenity-js/assertions'
|
|
151
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
152
|
+
* import { Switch } from '@serenity-js/web'
|
|
153
|
+
*
|
|
154
|
+
* actorCalled('Bernie').attemptsTo(
|
|
155
|
+
* Switch.to(Page.whichName(includes(`photo-gallery`))),
|
|
156
|
+
* )
|
|
157
|
+
* ```
|
|
158
|
+
*
|
|
159
|
+
* @param expectation
|
|
160
|
+
*/
|
|
13
161
|
static whichName(expectation: Expectation<string>): QuestionAdapter<Page> {
|
|
14
162
|
return Question.about(`page which name does ${ expectation }`, async actor => {
|
|
15
163
|
const pages = await BrowseTheWeb.as(actor).allPages();
|
|
@@ -22,6 +170,24 @@ export abstract class Page implements Optional {
|
|
|
22
170
|
});
|
|
23
171
|
}
|
|
24
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Creates a {@apilink QuestionAdapter} that resolves to a {@apilink Page} which {@apilink Page.title}
|
|
175
|
+
* meets the {@apilink Expectation|`expectation`}.
|
|
176
|
+
*
|
|
177
|
+
* #### Switching to a page with the desired title
|
|
178
|
+
*
|
|
179
|
+
* ```ts
|
|
180
|
+
* import { includes } from '@serenity-js/assertions'
|
|
181
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
182
|
+
* import { Switch } from '@serenity-js/web'
|
|
183
|
+
*
|
|
184
|
+
* actorCalled('Bernie').attemptsTo(
|
|
185
|
+
* Switch.to(Page.whichTitle(includes(`Summer collection`))),
|
|
186
|
+
* )
|
|
187
|
+
* ```
|
|
188
|
+
*
|
|
189
|
+
* @param expectation
|
|
190
|
+
*/
|
|
25
191
|
static whichTitle(expectation: Expectation<string>): QuestionAdapter<Page> {
|
|
26
192
|
return Question.about(`page which title does ${ expectation }`, async actor => {
|
|
27
193
|
const pages = await BrowseTheWeb.as(actor).allPages();
|
|
@@ -34,6 +200,24 @@ export abstract class Page implements Optional {
|
|
|
34
200
|
});
|
|
35
201
|
}
|
|
36
202
|
|
|
203
|
+
/**
|
|
204
|
+
* Creates a {@apilink QuestionAdapter} that resolves to a {@apilink Page} which {@apilink Page.url}
|
|
205
|
+
* meets the {@apilink Expectation|`expectation`}.
|
|
206
|
+
*
|
|
207
|
+
* #### Switching to a page with the desired URL
|
|
208
|
+
*
|
|
209
|
+
* ```ts
|
|
210
|
+
* import { endsWith } from '@serenity-js/assertions'
|
|
211
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
212
|
+
* import { Switch } from '@serenity-js/web'
|
|
213
|
+
*
|
|
214
|
+
* actorCalled('Bernie').attemptsTo(
|
|
215
|
+
* Switch.to(Page.whichUrl(endsWith(`/gallery.html`))),
|
|
216
|
+
* )
|
|
217
|
+
* ```
|
|
218
|
+
*
|
|
219
|
+
* @param expectation
|
|
220
|
+
*/
|
|
37
221
|
static whichUrl(expectation: Expectation<string>): QuestionAdapter<Page> {
|
|
38
222
|
return Question.about(`page which URL does ${ expectation }`, async actor => {
|
|
39
223
|
const pages = await BrowseTheWeb.as(actor).allPages();
|
|
@@ -48,7 +232,7 @@ export abstract class Page implements Optional {
|
|
|
48
232
|
});
|
|
49
233
|
}
|
|
50
234
|
|
|
51
|
-
private static async findMatchingPage(expectationDescription: string, pages: Page[], matcher: (page: Page) => Promise<ExpectationOutcome
|
|
235
|
+
private static async findMatchingPage(expectationDescription: string, pages: Page[], matcher: (page: Page) => Promise<ExpectationOutcome>): Promise<Page> {
|
|
52
236
|
for (const page of pages) {
|
|
53
237
|
const outcome = await matcher(page);
|
|
54
238
|
|
|
@@ -61,84 +245,301 @@ export abstract class Page implements Optional {
|
|
|
61
245
|
}
|
|
62
246
|
|
|
63
247
|
constructor(
|
|
64
|
-
protected readonly
|
|
248
|
+
protected readonly session: BrowsingSession<Page<Native_Element_Type>>,
|
|
249
|
+
protected readonly rootLocator: RootLocator<Native_Element_Type>,
|
|
250
|
+
protected modalDialogHandler: ModalDialogHandler,
|
|
251
|
+
public readonly id: CorrelationId,
|
|
65
252
|
) {
|
|
253
|
+
ensure('session', session, isDefined());
|
|
254
|
+
ensure('rootLocator', rootLocator, isDefined());
|
|
255
|
+
ensure('modalDialogHandler', modalDialogHandler, isDefined());
|
|
256
|
+
ensure('id', id, isDefined());
|
|
66
257
|
}
|
|
67
258
|
|
|
68
259
|
/**
|
|
69
|
-
* @
|
|
70
|
-
* Retrieves the document title of the current top-level browsing context, equivalent to calling `document.title`.
|
|
260
|
+
* Creates a {@apilink PageElement}, retrieving an element located by {@apilink Selector}.
|
|
71
261
|
*
|
|
72
|
-
* @
|
|
262
|
+
* @param selector
|
|
263
|
+
*/
|
|
264
|
+
abstract locate(selector: Selector): PageElement<Native_Element_Type>;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Creates {@apilink PageElements}, retrieving a collection of elements located by {@apilink Selector}.
|
|
73
268
|
*
|
|
74
|
-
* @
|
|
269
|
+
* @param selector
|
|
75
270
|
*/
|
|
76
|
-
abstract
|
|
271
|
+
abstract locateAll(selector: Selector): PageElements<Native_Element_Type>;
|
|
77
272
|
|
|
78
273
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
274
|
+
* Navigate to a given destination, specified as an absolute URL
|
|
275
|
+
* or a path relative to any base URL configured in your web test integration tool.
|
|
276
|
+
*
|
|
277
|
+
* #### Learn more
|
|
81
278
|
*
|
|
82
|
-
*
|
|
279
|
+
* - [WebdriverIO: Configuration Options](https://webdriver.io/docs/options/#baseurl)
|
|
280
|
+
* - [Playwright: Browser](https://playwright.dev/docs/api/class-browser#browser-new-context)
|
|
281
|
+
* - [Playwright: Test Options](https://playwright.dev/docs/api/class-testoptions#test-options-base-url)
|
|
282
|
+
* - [Protractor: Configuration](https://github.com/angular/protractor/blob/master/lib/config.ts)
|
|
283
|
+
*
|
|
284
|
+
* @param destination
|
|
83
285
|
*/
|
|
84
|
-
abstract
|
|
286
|
+
abstract navigateTo(destination: string): Promise<void>;
|
|
85
287
|
|
|
86
288
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
289
|
+
* Causes the browser to traverse one step backward in the joint session history
|
|
290
|
+
* of the current {@apilink Page} (the current top-level browsing context).
|
|
89
291
|
*
|
|
90
|
-
*
|
|
292
|
+
* This is equivalent to pressing the back button in the browser UI,
|
|
293
|
+
* or calling [`window.history.back`](https://developer.mozilla.org/en-US/docs/Web/API/History/back).
|
|
91
294
|
*/
|
|
92
|
-
abstract
|
|
295
|
+
abstract navigateBack(): Promise<void>;
|
|
93
296
|
|
|
94
297
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
298
|
+
* Causes the browser to traverse one step forward in the joint session history
|
|
299
|
+
* of the current {@apilink Page} (the current top-level browsing context).
|
|
97
300
|
*
|
|
98
|
-
*
|
|
301
|
+
* This is equivalent to pressing the back button in the browser UI,
|
|
302
|
+
* or calling [`window.history.forward`](https://developer.mozilla.org/en-US/docs/Web/API/History/forward).
|
|
99
303
|
*/
|
|
100
|
-
abstract
|
|
304
|
+
abstract navigateForward(): Promise<void>;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Causes the browser to reload the {@apilink Page} in the current top-level browsing context.
|
|
308
|
+
*/
|
|
309
|
+
abstract reload(): Promise<void>;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Send a sequence of {@apilink Key} strokes to the active element.
|
|
313
|
+
*
|
|
314
|
+
* @param keys
|
|
315
|
+
* Keys to enter
|
|
316
|
+
*/
|
|
317
|
+
abstract sendKeys(keys: Array<Key | string>): Promise<void>;
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Schedules a command to execute JavaScript in the context of the currently selected frame or window.
|
|
321
|
+
*
|
|
322
|
+
* The script fragment will be executed as the body of an anonymous function.
|
|
323
|
+
* If the script is provided as a function object, that function will be converted to a string for injection
|
|
324
|
+
* into the target window.
|
|
325
|
+
*
|
|
326
|
+
* Any arguments provided in addition to the script will be included as script arguments and may be referenced
|
|
327
|
+
* using the `arguments` object. Arguments may be a `boolean`, `number`, `string` or `WebElement`.
|
|
328
|
+
* Arrays and objects may also be used as script arguments as long as each item adheres
|
|
329
|
+
* to the types previously mentioned.
|
|
330
|
+
*
|
|
331
|
+
* The script may refer to any variables accessible from the current window.
|
|
332
|
+
* Furthermore, the script will execute in the window's context, thus `document` may be used to refer
|
|
333
|
+
* to the current document. Any local variables will not be available once the script has finished executing,
|
|
334
|
+
* though global variables will persist.
|
|
335
|
+
*
|
|
336
|
+
* If the script has a return value (i.e. if the script contains a `return` statement),
|
|
337
|
+
* then the following steps will be taken for resolving this functions return value:
|
|
338
|
+
*
|
|
339
|
+
* - For a {@apilink PageElement}, the value will resolve to a [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement)
|
|
340
|
+
* - `null` and `undefined` return values will resolve to `null`
|
|
341
|
+
* - `boolean`, `number`, and `string` values will resolve as is
|
|
342
|
+
* - Functions will resolve to their string representation
|
|
343
|
+
* - For arrays and objects, each member item will be converted according to the rules above
|
|
344
|
+
*
|
|
345
|
+
* #### Use injected JavaScript to retrieve information about a HTMLElement
|
|
346
|
+
*
|
|
347
|
+
* ```ts
|
|
348
|
+
* BrowseTheWeb.as(actor).executeAsyncScript(`
|
|
349
|
+
* return arguments[0].tagName;
|
|
350
|
+
* `, PageElement.located(By.css('h1')).describedAs('header'))
|
|
351
|
+
*
|
|
352
|
+
* // returns a Promise that resolves to 'h1'
|
|
353
|
+
* ```
|
|
354
|
+
*
|
|
355
|
+
* #### Learn more
|
|
356
|
+
* - [Selenium WebDriver: JavaScript Executor](https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/JavascriptExecutor.html#executeAsyncScript-java.lang.String-java.lang.Object...-)
|
|
357
|
+
* - {@apilink Page.lastScriptExecutionResult}
|
|
358
|
+
*
|
|
359
|
+
* @param script
|
|
360
|
+
* @param args
|
|
361
|
+
*/
|
|
362
|
+
abstract executeScript<Result, InnerArguments extends any[]>(
|
|
363
|
+
script: string | ((...parameters: InnerArguments) => Result),
|
|
364
|
+
...args: InnerArguments
|
|
365
|
+
): Promise<Result>;
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Schedules a command to execute asynchronous JavaScript in the context of the currently selected frame or window.
|
|
369
|
+
*
|
|
370
|
+
* The script fragment will be executed as the body of an anonymous function.
|
|
371
|
+
* If the script is provided as a function object, that function will be converted to a string for injection
|
|
372
|
+
* into the target window.
|
|
373
|
+
*
|
|
374
|
+
* Any arguments provided in addition to the script will be included as script arguments and may be referenced
|
|
375
|
+
* using the `arguments` object. Arguments may be a `boolean`, `number`, `string` or `WebElement`
|
|
376
|
+
* Arrays and objects may also be used as script arguments as long as each item adheres
|
|
377
|
+
* to the types previously mentioned.
|
|
378
|
+
*
|
|
379
|
+
* Unlike executing synchronous JavaScript with {@apilink Page.executeScript},
|
|
380
|
+
* scripts executed with this function must explicitly signal they are finished by invoking the provided callback.
|
|
381
|
+
*
|
|
382
|
+
* This callback will always be injected into the executed function as the last argument,
|
|
383
|
+
* and thus may be referenced with `arguments[arguments.length - 1]`.
|
|
384
|
+
*
|
|
385
|
+
* The following steps will be taken for resolving this functions return value against
|
|
386
|
+
* the first argument to the script's callback function:
|
|
387
|
+
*
|
|
388
|
+
* - For a {@apilink PageElement}, the value will resolve to a [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement)
|
|
389
|
+
* - `null` and `undefined` return values will resolve to `null`
|
|
390
|
+
* - `boolean`, `number`, and `string` values will resolve as is
|
|
391
|
+
* - Functions will resolve to their string representation
|
|
392
|
+
* - For arrays and objects, each member item will be converted according to the rules above
|
|
393
|
+
*
|
|
394
|
+
* #### Perform a sleep in the browser under test>
|
|
395
|
+
*
|
|
396
|
+
* ```ts
|
|
397
|
+
* BrowseTheWeb.as(actor).executeAsyncScript(`
|
|
398
|
+
* var delay = arguments[0];
|
|
399
|
+
* var callback = arguments[arguments.length - 1];
|
|
400
|
+
*
|
|
401
|
+
* window.setTimeout(callback, delay);
|
|
402
|
+
* `, 500)
|
|
403
|
+
* ```
|
|
404
|
+
*
|
|
405
|
+
* #### Return a value asynchronously
|
|
406
|
+
*
|
|
407
|
+
* ```ts
|
|
408
|
+
* BrowseTheWeb.as(actor).executeAsyncScript(`
|
|
409
|
+
* var callback = arguments[arguments.length - 1];
|
|
410
|
+
*
|
|
411
|
+
* callback('some return value')
|
|
412
|
+
* `).then(value => doSomethingWithThe(value))
|
|
413
|
+
* ```
|
|
414
|
+
*
|
|
415
|
+
* #### Learn more
|
|
416
|
+
* - [Selenium WebDriver: JavaScript Executor](https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/JavascriptExecutor.html#executeAsyncScript-java.lang.String-java.lang.Object...-)
|
|
417
|
+
* - {@apilink Page.lastScriptExecutionResult}
|
|
418
|
+
*
|
|
419
|
+
* @param script
|
|
420
|
+
* @param args
|
|
421
|
+
*/
|
|
422
|
+
abstract executeAsyncScript<Result, Parameters extends any[]>(
|
|
423
|
+
script: string | ((...args: [ ...parameters: Parameters, callback: (result: Result) => void ]) => void),
|
|
424
|
+
...args: Parameters
|
|
425
|
+
): Promise<Result>;
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Returns the last result of calling {@apilink Page.executeAsyncScript}
|
|
429
|
+
* or {@apilink Page.executeScript}
|
|
430
|
+
*/
|
|
431
|
+
abstract lastScriptExecutionResult<R = any>(): R;
|
|
101
432
|
|
|
102
433
|
/**
|
|
103
|
-
*
|
|
104
|
-
* Returns the actual viewport size available for the given page,
|
|
105
|
-
* excluding any scrollbars.
|
|
434
|
+
* Take a screenshot of the top-level browsing context's viewport.
|
|
106
435
|
*
|
|
107
|
-
* @
|
|
436
|
+
* @throws {@apilink BrowserWindowClosedError}
|
|
437
|
+
* When the page you're trying to take the screenshot of has already been closed
|
|
438
|
+
*
|
|
439
|
+
* @return
|
|
440
|
+
* A promise that will resolve to a base64-encoded screenshot PNG
|
|
441
|
+
*/
|
|
442
|
+
abstract takeScreenshot(): Promise<string>;
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Retrieves a cookie identified by `name` and visible to this {@apilink Page}.
|
|
446
|
+
*
|
|
447
|
+
* @param name
|
|
448
|
+
*/
|
|
449
|
+
abstract cookie(name: string): Promise<Cookie>;
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Adds a single cookie with {@apilink CookieData} to the cookie store associated
|
|
453
|
+
* with the active {@apilink Page}'s address.
|
|
454
|
+
*
|
|
455
|
+
* @param cookieData
|
|
456
|
+
*/
|
|
457
|
+
abstract setCookie(cookieData: CookieData): Promise<void>;
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Removes all the cookies.
|
|
461
|
+
*/
|
|
462
|
+
abstract deleteAllCookies(): Promise<void>;
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Retrieves the document title of the current top-level browsing context, equivalent to calling `document.title`.
|
|
466
|
+
*
|
|
467
|
+
* #### Learn more
|
|
468
|
+
* - [Mozilla Developer Network: Document title](https://developer.mozilla.org/en-US/docs/Web/API/Document/title)
|
|
469
|
+
*/
|
|
470
|
+
abstract title(): Promise<string>;
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Retrieves the URL of the current top-level browsing context.
|
|
474
|
+
*/
|
|
475
|
+
abstract url(): Promise<URL>;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Retrieves the name of the current top-level browsing context.
|
|
479
|
+
*/
|
|
480
|
+
abstract name(): Promise<string>;
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Checks if a given window / tab / page is open and can be switched to, e.g. it's not closed.
|
|
484
|
+
*/
|
|
485
|
+
abstract isPresent(): Promise<boolean>;
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Returns the actual viewport size available for the given page,
|
|
489
|
+
* excluding any scrollbars.
|
|
108
490
|
*/
|
|
109
491
|
abstract viewportSize(): Promise<{ width: number, height: number }>;
|
|
110
492
|
|
|
111
493
|
/**
|
|
494
|
+
* Sets ths size of the visible viewport to desired dimensions.
|
|
112
495
|
*
|
|
113
496
|
* @param size
|
|
114
497
|
*/
|
|
115
498
|
abstract setViewportSize(size: { width: number, height: number }): Promise<void>;
|
|
116
499
|
|
|
117
500
|
/**
|
|
118
|
-
*
|
|
119
|
-
*
|
|
501
|
+
* Switches the current browsing context to the given page
|
|
502
|
+
* and returns an object that allows the caller to switch back
|
|
503
|
+
* to the previous context when needed.
|
|
120
504
|
*
|
|
121
|
-
*
|
|
505
|
+
* ## Learn more
|
|
506
|
+
* - {@apilink Switch}
|
|
507
|
+
* - {@apilink Switchable}
|
|
122
508
|
*/
|
|
123
|
-
|
|
509
|
+
async switchTo(): Promise<SwitchableOrigin> {
|
|
510
|
+
|
|
511
|
+
const originalPage = await this.session.currentPage();
|
|
512
|
+
|
|
513
|
+
await this.session.changeCurrentPageTo(this);
|
|
514
|
+
|
|
515
|
+
return {
|
|
516
|
+
switchBack: async (): Promise<void> => {
|
|
517
|
+
await this.session.changeCurrentPageTo(originalPage);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
124
521
|
|
|
125
522
|
/**
|
|
126
|
-
*
|
|
127
|
-
* Closes the given page.
|
|
128
|
-
*
|
|
129
|
-
* @returns {Promise<void>}
|
|
523
|
+
* Closes this page.
|
|
130
524
|
*/
|
|
131
525
|
abstract close(): Promise<void>;
|
|
132
526
|
|
|
133
527
|
/**
|
|
134
|
-
*
|
|
135
|
-
* Closes any open pages, except for this one.
|
|
136
|
-
*
|
|
137
|
-
* @returns {Promise<void>}
|
|
528
|
+
* Closes any open pages, except for this one.
|
|
138
529
|
*/
|
|
139
530
|
abstract closeOthers(): Promise<void>;
|
|
140
531
|
|
|
532
|
+
/**
|
|
533
|
+
* Returns the {@apilink ModalDialogHandler} for the current {@apilink Page}.
|
|
534
|
+
*/
|
|
535
|
+
modalDialog(): ModalDialogHandler {
|
|
536
|
+
return this.modalDialogHandler;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Returns a description of this Page and its ID.
|
|
541
|
+
*/
|
|
141
542
|
toString(): string {
|
|
142
|
-
return `page (
|
|
543
|
+
return `page (id=${ this.id.value })`;
|
|
143
544
|
}
|
|
144
545
|
}
|