@serenity-js/web 3.0.0-rc.9 → 3.0.1
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 +337 -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,150 +1,127 @@
|
|
|
1
1
|
import { Activity, Answerable, AnswersQuestions, Interaction, Task, UsesAbilities } from '@serenity-js/core';
|
|
2
|
-
import {
|
|
2
|
+
import { Switchable } from '../models';
|
|
3
3
|
/**
|
|
4
|
-
* @
|
|
5
|
-
*
|
|
6
|
-
* to switch to a different [frame](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/frame),
|
|
7
|
-
* [inline frame](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe),
|
|
8
|
-
* or browser window/tab.
|
|
9
|
-
*
|
|
10
|
-
* @example <caption>Lean Page Object describing a login form, embedded in an iframe</caption>
|
|
11
|
-
*
|
|
12
|
-
* import { Target } from '@serenity-js/protractor';
|
|
13
|
-
* import { by } from 'protractor';
|
|
14
|
-
*
|
|
15
|
-
* class LoginForm {
|
|
16
|
-
* static iframe = Target.the('login form').located(by.tagName('iframe'));
|
|
17
|
-
* static usernameField = Target.the('username field').located(by.css('[data-test="username"]'));
|
|
18
|
-
* static passwordField = Target.the('password field').located(by.css('[data-test="password"]'));
|
|
19
|
-
* static submitButton = Target.the('submit button').located(by.css(`button[type='submit']`));
|
|
20
|
-
* }
|
|
21
|
-
*
|
|
22
|
-
* @example <caption>Switch to an iframe and back</caption>
|
|
23
|
-
*
|
|
24
|
-
* import { actorCalled } from '@serenity-js/core';
|
|
25
|
-
* import { BrowseTheWeb, Switch, Enter, Click } from '@serenity-js/protractor';
|
|
26
|
-
* import { protractor } from 'protractor';
|
|
27
|
-
*
|
|
28
|
-
* actorCalled('Francesca')
|
|
29
|
-
* .whoCan(BrowseTheWeb.using(protractor.browser))
|
|
30
|
-
* .attemptsTo(
|
|
31
|
-
* Switch.toFrame(LoginForm.iframe),
|
|
32
|
-
*
|
|
33
|
-
* Enter.theValue('francesca@example.org').into(LoginForm.usernameField),
|
|
34
|
-
* Enter.theValue('correct-horse-battery-staple').into(LoginForm.passwordField),
|
|
35
|
-
* Click.on(LoginForm.submitButton),
|
|
36
|
-
*
|
|
37
|
-
* Switch.toParentFrame(),
|
|
38
|
-
* );
|
|
4
|
+
* Instructs an {@apilink Actor|actor} who has the {@apilink Ability|ability} to {@apilink BrowseTheWeb}
|
|
5
|
+
* to switch the context for future activities to a {@apilink Switchable}, such as a {@apilink Page} or a {@apilink PageElement}.
|
|
39
6
|
*
|
|
40
|
-
*
|
|
7
|
+
* Please note that when the {@apilink PageElement} implementing {@apilink Switchable} represents an {@apilink iframe},
|
|
8
|
+
* using {@apilink Switch} will result in switching the top-level browsing context to that {@apilink iframe}.
|
|
41
9
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
10
|
+
* When the {@apilink PageElement} represents any other [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement),
|
|
11
|
+
* using {@apilink Switch} sets [`HTMLElement#focus`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus)
|
|
12
|
+
* on the specified element. Assuming it can be focused.
|
|
45
13
|
*
|
|
46
|
-
*
|
|
47
|
-
* .whoCan(BrowseTheWeb.using(protractor.browser))
|
|
48
|
-
* .attemptsTo(
|
|
49
|
-
* Switch.toFrame(LoginForm.iframe).and(
|
|
50
|
-
* Enter.theValue('francesca@example.org').into(LoginForm.usernameField),
|
|
51
|
-
* Enter.theValue('correct-horse-battery-staple').into(LoginForm.passwordField),
|
|
52
|
-
* Click.on(LoginForm.submitButton),
|
|
53
|
-
* ),
|
|
54
|
-
* // Note that Switch.toParentFrame() is invoked automatically
|
|
55
|
-
* );
|
|
14
|
+
* **Note:** The focused element is the element which will receive keyboard {@apilink Press} events by default.
|
|
56
15
|
*
|
|
57
|
-
*
|
|
16
|
+
* ## Perform activities in the context of an iframe
|
|
58
17
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
20
|
+
* import { By, Click, Enter, PageElement, Switch } from '@serenity-js/web'
|
|
62
21
|
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
22
|
+
* // Lean Page Object describing a login form, embedded in an iframe
|
|
23
|
+
* class LoginForm {
|
|
24
|
+
* static iframe = () =>
|
|
25
|
+
* PageElement.located(By.css('iframe'))
|
|
26
|
+
* .describedAs('login form')
|
|
67
27
|
*
|
|
68
|
-
*
|
|
28
|
+
* static usernameField = () =>
|
|
29
|
+
* PageElement.located(By.css('[data-testid="username"]'))
|
|
30
|
+
* .describedAs('username field')
|
|
69
31
|
*
|
|
70
|
-
*
|
|
32
|
+
* static passwordField = () =>
|
|
33
|
+
* PageElement.located(By.css('[data-testid="password"]'))
|
|
34
|
+
* .describedAs('password field')
|
|
71
35
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* import { actorCalled } from '@serenity-js/core';
|
|
78
|
-
* import { BrowseTheWeb, Switch, Close } from '@serenity-js/protractor';
|
|
79
|
-
* import { protractor } from 'protractor';
|
|
80
|
-
*
|
|
81
|
-
* actorCalled('Francesca')
|
|
82
|
-
* .whoCan(BrowseTheWeb.using(protractor.browser))
|
|
83
|
-
* .attemptsTo(
|
|
84
|
-
* Switch.toNewWindow().and(
|
|
85
|
-
* // perform some activities in the context of the new window
|
|
86
|
-
*
|
|
87
|
-
* Close.currentWindow()
|
|
88
|
-
* ),
|
|
89
|
-
*
|
|
90
|
-
* // Note that Switch.toOriginalWindow() is invoked automatically
|
|
91
|
-
* );
|
|
36
|
+
* static submitButton = () =>
|
|
37
|
+
* PageElement.located(By.css('button[type="submit"]'))
|
|
38
|
+
* .describedAs('submit button')
|
|
39
|
+
* }
|
|
92
40
|
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
41
|
+
* await actorCalled('Francesca')
|
|
42
|
+
* .attemptsTo(
|
|
43
|
+
* Switch.to(LoginForm.iframe).and(
|
|
44
|
+
* Enter.theValue('francesca@example.org').into(LoginForm.usernameField()),
|
|
45
|
+
* Enter.theValue('correct-horse-battery-staple').into(LoginForm.passwordField()),
|
|
46
|
+
* Click.on(LoginForm.submitButton()),
|
|
47
|
+
* )
|
|
48
|
+
* )
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* ## Perform activities in the context of another page
|
|
52
|
+
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
55
|
+
* import { Click, Enter, Switch } from '@serenity-js/web'
|
|
56
|
+
*
|
|
57
|
+
* await actorCalled('Francesca')
|
|
58
|
+
* .whoCan(BrowseTheWebWithWebdriverIO.using(browser))
|
|
59
|
+
* .attemptsTo(
|
|
60
|
+
* Switch.to(Page.whichName(startsWith('popup'))).and(
|
|
61
|
+
* // perform some activities in the context of the new window
|
|
62
|
+
*
|
|
63
|
+
* // optionally, close the browser tab
|
|
64
|
+
* Page.current().close(),
|
|
65
|
+
* ),
|
|
66
|
+
*
|
|
67
|
+
* // Note that switching back to the original page happens automatically
|
|
68
|
+
* // after the last activity from the list finishes
|
|
69
|
+
* )
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* ## Perform activities in the context of a focused page element
|
|
73
|
+
*
|
|
74
|
+
* ```ts
|
|
75
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
76
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
77
|
+
* import { Key, PageElement, Press, Switch, Value } from '@serenity-js/web'
|
|
78
|
+
*
|
|
79
|
+
* const inputField = () =>
|
|
80
|
+
* PageElement.located(By.css('input'));
|
|
81
|
+
*
|
|
82
|
+
* await actorCalled('Francesca')
|
|
83
|
+
* .whoCan(BrowseTheWebWithWebdriverIO.using(browser))
|
|
84
|
+
* .attemptsTo(
|
|
85
|
+
* Switch.to(inputField()).and(
|
|
86
|
+
* Press.the('h', 'e', 'l', 'l', 'o'),
|
|
87
|
+
* Press.the(Key.Tab),
|
|
88
|
+
* ),
|
|
89
|
+
* Ensure.that(Value.of(inputField()), equals('hello'))
|
|
90
|
+
* )
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* ## Learn more
|
|
94
|
+
*
|
|
95
|
+
* - {@apilink BrowseTheWeb}
|
|
96
|
+
* - {@apilink Switchable}
|
|
97
|
+
* - {@apilink SwitchableOrigin}
|
|
98
|
+
*
|
|
99
|
+
* @group Activities
|
|
95
100
|
*/
|
|
96
|
-
export declare class Switch {
|
|
101
|
+
export declare class Switch extends Interaction {
|
|
102
|
+
private readonly switchable;
|
|
97
103
|
/**
|
|
98
|
-
* @
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* or an [inline frame](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe)
|
|
102
|
-
* identified by its name, index or `Question<ElementFinder>`.
|
|
104
|
+
* Instructs the {@apilink Actor}
|
|
105
|
+
* to switch the context for future activities to a {@apilink Switchable},
|
|
106
|
+
* such as a {@apilink Page} or a {@apilink PageElement}.
|
|
103
107
|
*
|
|
104
|
-
* @param
|
|
105
|
-
*
|
|
106
|
-
* @returns {SwitchToFrame}
|
|
107
|
-
*
|
|
108
|
-
* @see {@link Switch.toParentFrame}
|
|
109
|
-
* @see {@link Switch.toDefaultContent}
|
|
110
|
-
* @see {@link Target}
|
|
108
|
+
* @param switchable
|
|
111
109
|
*/
|
|
112
|
-
static
|
|
110
|
+
static to(switchable: Answerable<Switchable>): Switch;
|
|
111
|
+
protected constructor(switchable: Answerable<Switchable>);
|
|
113
112
|
/**
|
|
114
|
-
* @
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* If the current context is the top-level browsing context, the context remains unchanged.
|
|
113
|
+
* Instructs the {@apilink Actor}
|
|
114
|
+
* to switch the context for future activities to a {@apilink Switchable},
|
|
115
|
+
* such as a {@apilink Page} or a {@apilink PageElement},
|
|
116
|
+
* perform a sequence of `activities`, and then switch the context back.
|
|
120
117
|
*
|
|
121
|
-
* @
|
|
122
|
-
*
|
|
123
|
-
* @see {@link Switch.toFrame}
|
|
124
|
-
* @see https://w3c.github.io/webdriver/#switch-to-parent-frame
|
|
125
|
-
* @see https://w3c.github.io/webdriver/#dfn-current-browsing-context
|
|
118
|
+
* @param activities
|
|
119
|
+
* A sequence of activities to perform
|
|
126
120
|
*/
|
|
127
|
-
|
|
121
|
+
and(...activities: Activity[]): Task;
|
|
128
122
|
/**
|
|
129
|
-
* @
|
|
130
|
-
* Switches the current [browsing context](https://w3c.github.io/webdriver/#dfn-current-browsing-context)
|
|
131
|
-
* for future commands to the first frame on the page, or the main document
|
|
132
|
-
* when a page contains [`iframe`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe)s.
|
|
133
|
-
*
|
|
134
|
-
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
135
|
-
*
|
|
136
|
-
* @see {@link Switch.toFrame}
|
|
123
|
+
* @inheritDoc
|
|
137
124
|
*/
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* @package
|
|
142
|
-
*/
|
|
143
|
-
declare class SwitchToFrame extends Interaction {
|
|
144
|
-
private readonly targetOrIndex;
|
|
145
|
-
constructor(targetOrIndex: Answerable<PageElement | number | string>);
|
|
146
|
-
and(...activities: Activity[]): Task;
|
|
147
|
-
performAs(actor: UsesAbilities & AnswersQuestions): PromiseLike<void>;
|
|
148
|
-
toString(): string;
|
|
125
|
+
performAs(actor: UsesAbilities & AnswersQuestions): Promise<void>;
|
|
149
126
|
}
|
|
150
|
-
|
|
127
|
+
//# sourceMappingURL=Switch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../../src/screenplay/interactions/Switch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAS,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEpH,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiGG;AACH,qBAAa,MAAO,SAAQ,WAAW;IAab,OAAO,CAAC,QAAQ,CAAC,UAAU;IAXjD;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,GAAG,MAAM;IAIrD,SAAS,aAA8B,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC;IAIzE;;;;;;;;OAQG;IACH,GAAG,CAAC,GAAG,UAAU,EAAE,QAAQ,EAAE,GAAG,IAAI;IAIpC;;OAEG;IACG,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;CAK1E"}
|
|
@@ -2,208 +2,157 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Switch = void 0;
|
|
4
4
|
const core_1 = require("@serenity-js/core");
|
|
5
|
-
const abilities_1 = require("../abilities");
|
|
6
5
|
/**
|
|
7
|
-
* @
|
|
8
|
-
*
|
|
9
|
-
* to switch to a different [frame](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/frame),
|
|
10
|
-
* [inline frame](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe),
|
|
11
|
-
* or browser window/tab.
|
|
12
|
-
*
|
|
13
|
-
* @example <caption>Lean Page Object describing a login form, embedded in an iframe</caption>
|
|
14
|
-
*
|
|
15
|
-
* import { Target } from '@serenity-js/protractor';
|
|
16
|
-
* import { by } from 'protractor';
|
|
17
|
-
*
|
|
18
|
-
* class LoginForm {
|
|
19
|
-
* static iframe = Target.the('login form').located(by.tagName('iframe'));
|
|
20
|
-
* static usernameField = Target.the('username field').located(by.css('[data-test="username"]'));
|
|
21
|
-
* static passwordField = Target.the('password field').located(by.css('[data-test="password"]'));
|
|
22
|
-
* static submitButton = Target.the('submit button').located(by.css(`button[type='submit']`));
|
|
23
|
-
* }
|
|
24
|
-
*
|
|
25
|
-
* @example <caption>Switch to an iframe and back</caption>
|
|
26
|
-
*
|
|
27
|
-
* import { actorCalled } from '@serenity-js/core';
|
|
28
|
-
* import { BrowseTheWeb, Switch, Enter, Click } from '@serenity-js/protractor';
|
|
29
|
-
* import { protractor } from 'protractor';
|
|
30
|
-
*
|
|
31
|
-
* actorCalled('Francesca')
|
|
32
|
-
* .whoCan(BrowseTheWeb.using(protractor.browser))
|
|
33
|
-
* .attemptsTo(
|
|
34
|
-
* Switch.toFrame(LoginForm.iframe),
|
|
35
|
-
*
|
|
36
|
-
* Enter.theValue('francesca@example.org').into(LoginForm.usernameField),
|
|
37
|
-
* Enter.theValue('correct-horse-battery-staple').into(LoginForm.passwordField),
|
|
38
|
-
* Click.on(LoginForm.submitButton),
|
|
39
|
-
*
|
|
40
|
-
* Switch.toParentFrame(),
|
|
41
|
-
* );
|
|
42
|
-
*
|
|
43
|
-
* @example <caption>Perform activities in the context of an iframe</caption>
|
|
44
|
-
*
|
|
45
|
-
* import { actorCalled } from '@serenity-js/core';
|
|
46
|
-
* import { BrowseTheWeb, Switch, Enter, Click } from '@serenity-js/protractor';
|
|
47
|
-
* import { protractor } from 'protractor';
|
|
48
|
-
*
|
|
49
|
-
* actorCalled('Francesca')
|
|
50
|
-
* .whoCan(BrowseTheWeb.using(protractor.browser))
|
|
51
|
-
* .attemptsTo(
|
|
52
|
-
* Switch.toFrame(LoginForm.iframe).and(
|
|
53
|
-
* Enter.theValue('francesca@example.org').into(LoginForm.usernameField),
|
|
54
|
-
* Enter.theValue('correct-horse-battery-staple').into(LoginForm.passwordField),
|
|
55
|
-
* Click.on(LoginForm.submitButton),
|
|
56
|
-
* ),
|
|
57
|
-
* // Note that Switch.toParentFrame() is invoked automatically
|
|
58
|
-
* );
|
|
59
|
-
*
|
|
60
|
-
* @example <caption>Switch to a new window/tab and back</caption>
|
|
61
|
-
*
|
|
62
|
-
* import { actorCalled } from '@serenity-js/core';
|
|
63
|
-
* import { BrowseTheWeb, Switch, Close } from '@serenity-js/protractor';
|
|
64
|
-
* import { protractor } from 'protractor';
|
|
6
|
+
* Instructs an {@apilink Actor|actor} who has the {@apilink Ability|ability} to {@apilink BrowseTheWeb}
|
|
7
|
+
* to switch the context for future activities to a {@apilink Switchable}, such as a {@apilink Page} or a {@apilink PageElement}.
|
|
65
8
|
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* .attemptsTo(
|
|
69
|
-
* Switch.toNewWindow(), // or: Switch.toWindow(...)
|
|
9
|
+
* Please note that when the {@apilink PageElement} implementing {@apilink Switchable} represents an {@apilink iframe},
|
|
10
|
+
* using {@apilink Switch} will result in switching the top-level browsing context to that {@apilink iframe}.
|
|
70
11
|
*
|
|
71
|
-
*
|
|
12
|
+
* When the {@apilink PageElement} represents any other [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement),
|
|
13
|
+
* using {@apilink Switch} sets [`HTMLElement#focus`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus)
|
|
14
|
+
* on the specified element. Assuming it can be focused.
|
|
72
15
|
*
|
|
73
|
-
*
|
|
16
|
+
* **Note:** The focused element is the element which will receive keyboard {@apilink Press} events by default.
|
|
74
17
|
*
|
|
75
|
-
*
|
|
76
|
-
* );
|
|
18
|
+
* ## Perform activities in the context of an iframe
|
|
77
19
|
*
|
|
78
|
-
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
22
|
+
* import { By, Click, Enter, PageElement, Switch } from '@serenity-js/web'
|
|
79
23
|
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
24
|
+
* // Lean Page Object describing a login form, embedded in an iframe
|
|
25
|
+
* class LoginForm {
|
|
26
|
+
* static iframe = () =>
|
|
27
|
+
* PageElement.located(By.css('iframe'))
|
|
28
|
+
* .describedAs('login form')
|
|
83
29
|
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* Switch.toNewWindow().and(
|
|
88
|
-
* // perform some activities in the context of the new window
|
|
30
|
+
* static usernameField = () =>
|
|
31
|
+
* PageElement.located(By.css('[data-testid="username"]'))
|
|
32
|
+
* .describedAs('username field')
|
|
89
33
|
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
34
|
+
* static passwordField = () =>
|
|
35
|
+
* PageElement.located(By.css('[data-testid="password"]'))
|
|
36
|
+
* .describedAs('password field')
|
|
92
37
|
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
38
|
+
* static submitButton = () =>
|
|
39
|
+
* PageElement.located(By.css('button[type="submit"]'))
|
|
40
|
+
* .describedAs('submit button')
|
|
41
|
+
* }
|
|
95
42
|
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
43
|
+
* await actorCalled('Francesca')
|
|
44
|
+
* .attemptsTo(
|
|
45
|
+
* Switch.to(LoginForm.iframe).and(
|
|
46
|
+
* Enter.theValue('francesca@example.org').into(LoginForm.usernameField()),
|
|
47
|
+
* Enter.theValue('correct-horse-battery-staple').into(LoginForm.passwordField()),
|
|
48
|
+
* Click.on(LoginForm.submitButton()),
|
|
49
|
+
* )
|
|
50
|
+
* )
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* ## Perform activities in the context of another page
|
|
54
|
+
*
|
|
55
|
+
* ```ts
|
|
56
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
57
|
+
* import { Click, Enter, Switch } from '@serenity-js/web'
|
|
58
|
+
*
|
|
59
|
+
* await actorCalled('Francesca')
|
|
60
|
+
* .whoCan(BrowseTheWebWithWebdriverIO.using(browser))
|
|
61
|
+
* .attemptsTo(
|
|
62
|
+
* Switch.to(Page.whichName(startsWith('popup'))).and(
|
|
63
|
+
* // perform some activities in the context of the new window
|
|
64
|
+
*
|
|
65
|
+
* // optionally, close the browser tab
|
|
66
|
+
* Page.current().close(),
|
|
67
|
+
* ),
|
|
68
|
+
*
|
|
69
|
+
* // Note that switching back to the original page happens automatically
|
|
70
|
+
* // after the last activity from the list finishes
|
|
71
|
+
* )
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* ## Perform activities in the context of a focused page element
|
|
75
|
+
*
|
|
76
|
+
* ```ts
|
|
77
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
78
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
79
|
+
* import { Key, PageElement, Press, Switch, Value } from '@serenity-js/web'
|
|
80
|
+
*
|
|
81
|
+
* const inputField = () =>
|
|
82
|
+
* PageElement.located(By.css('input'));
|
|
83
|
+
*
|
|
84
|
+
* await actorCalled('Francesca')
|
|
85
|
+
* .whoCan(BrowseTheWebWithWebdriverIO.using(browser))
|
|
86
|
+
* .attemptsTo(
|
|
87
|
+
* Switch.to(inputField()).and(
|
|
88
|
+
* Press.the('h', 'e', 'l', 'l', 'o'),
|
|
89
|
+
* Press.the(Key.Tab),
|
|
90
|
+
* ),
|
|
91
|
+
* Ensure.that(Value.of(inputField()), equals('hello'))
|
|
92
|
+
* )
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* ## Learn more
|
|
96
|
+
*
|
|
97
|
+
* - {@apilink BrowseTheWeb}
|
|
98
|
+
* - {@apilink Switchable}
|
|
99
|
+
* - {@apilink SwitchableOrigin}
|
|
100
|
+
*
|
|
101
|
+
* @group Activities
|
|
98
102
|
*/
|
|
99
|
-
class Switch {
|
|
103
|
+
class Switch extends core_1.Interaction {
|
|
100
104
|
/**
|
|
101
|
-
* @
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* or an [inline frame](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe)
|
|
105
|
-
* identified by its name, index or `Question<ElementFinder>`.
|
|
106
|
-
*
|
|
107
|
-
* @param {Answerable<ElementFinder | number | string>} targetOrIndex
|
|
108
|
-
*
|
|
109
|
-
* @returns {SwitchToFrame}
|
|
105
|
+
* Instructs the {@apilink Actor}
|
|
106
|
+
* to switch the context for future activities to a {@apilink Switchable},
|
|
107
|
+
* such as a {@apilink Page} or a {@apilink PageElement}.
|
|
110
108
|
*
|
|
111
|
-
* @
|
|
112
|
-
* @see {@link Switch.toDefaultContent}
|
|
113
|
-
* @see {@link Target}
|
|
109
|
+
* @param switchable
|
|
114
110
|
*/
|
|
115
|
-
static
|
|
116
|
-
return new
|
|
111
|
+
static to(switchable) {
|
|
112
|
+
return new Switch(switchable);
|
|
113
|
+
}
|
|
114
|
+
constructor(switchable) {
|
|
115
|
+
super(`#actor switches to ${switchable}`);
|
|
116
|
+
this.switchable = switchable;
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
119
|
-
* @
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* If the current context is the top-level browsing context, the context remains unchanged.
|
|
125
|
-
*
|
|
126
|
-
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
119
|
+
* Instructs the {@apilink Actor}
|
|
120
|
+
* to switch the context for future activities to a {@apilink Switchable},
|
|
121
|
+
* such as a {@apilink Page} or a {@apilink PageElement},
|
|
122
|
+
* perform a sequence of `activities`, and then switch the context back.
|
|
127
123
|
*
|
|
128
|
-
* @
|
|
129
|
-
*
|
|
130
|
-
* @see https://w3c.github.io/webdriver/#dfn-current-browsing-context
|
|
124
|
+
* @param activities
|
|
125
|
+
* A sequence of activities to perform
|
|
131
126
|
*/
|
|
132
|
-
|
|
133
|
-
return new
|
|
127
|
+
and(...activities) {
|
|
128
|
+
return new SwitchAndPerformActivities(this.switchable, activities);
|
|
134
129
|
}
|
|
135
130
|
/**
|
|
136
|
-
* @
|
|
137
|
-
* Switches the current [browsing context](https://w3c.github.io/webdriver/#dfn-current-browsing-context)
|
|
138
|
-
* for future commands to the first frame on the page, or the main document
|
|
139
|
-
* when a page contains [`iframe`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe)s.
|
|
140
|
-
*
|
|
141
|
-
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
142
|
-
*
|
|
143
|
-
* @see {@link Switch.toFrame}
|
|
131
|
+
* @inheritDoc
|
|
144
132
|
*/
|
|
145
|
-
|
|
146
|
-
|
|
133
|
+
async performAs(actor) {
|
|
134
|
+
const switchable = await actor.answer(this.switchable);
|
|
135
|
+
await switchable.switchTo();
|
|
147
136
|
}
|
|
148
137
|
}
|
|
149
138
|
exports.Switch = Switch;
|
|
150
139
|
/**
|
|
151
140
|
* @package
|
|
152
141
|
*/
|
|
153
|
-
class
|
|
154
|
-
constructor(
|
|
155
|
-
super();
|
|
156
|
-
this.
|
|
157
|
-
}
|
|
158
|
-
and(...activities) {
|
|
159
|
-
return new SwitchToFrameAndPerformActivities(this.targetOrIndex, activities);
|
|
160
|
-
}
|
|
161
|
-
performAs(actor) {
|
|
162
|
-
return actor.answer(this.targetOrIndex)
|
|
163
|
-
.then((targetOrIndex) => {
|
|
164
|
-
return abilities_1.BrowseTheWeb.as(actor).switchToFrame(targetOrIndex);
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
toString() {
|
|
168
|
-
return `#actor switches to frame: ${this.targetOrIndex}`;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* @package
|
|
173
|
-
*/
|
|
174
|
-
class SwitchToFrameAndPerformActivities extends core_1.Task {
|
|
175
|
-
constructor(targetOrIndex, activities) {
|
|
176
|
-
super();
|
|
177
|
-
this.targetOrIndex = targetOrIndex;
|
|
142
|
+
class SwitchAndPerformActivities extends core_1.Task {
|
|
143
|
+
constructor(switchable, activities) {
|
|
144
|
+
super(`#actor switches to ${switchable}`);
|
|
145
|
+
this.switchable = switchable;
|
|
178
146
|
this.activities = activities;
|
|
179
147
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
* @package
|
|
189
|
-
*/
|
|
190
|
-
class SwitchToParentFrame extends core_1.Interaction {
|
|
191
|
-
performAs(actor) {
|
|
192
|
-
return abilities_1.BrowseTheWeb.as(actor).switchToParentFrame();
|
|
193
|
-
}
|
|
194
|
-
toString() {
|
|
195
|
-
return `#actor switches to parent frame`;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* @package
|
|
200
|
-
*/
|
|
201
|
-
class SwitchToDefaultContent extends core_1.Interaction {
|
|
202
|
-
performAs(actor) {
|
|
203
|
-
return abilities_1.BrowseTheWeb.as(actor).switchToDefaultContent();
|
|
204
|
-
}
|
|
205
|
-
toString() {
|
|
206
|
-
return `#actor switches to default content`;
|
|
148
|
+
/**
|
|
149
|
+
* @inheritDoc
|
|
150
|
+
*/
|
|
151
|
+
async performAs(actor) {
|
|
152
|
+
const switchable = await actor.answer(this.switchable);
|
|
153
|
+
const origin = await switchable.switchTo();
|
|
154
|
+
await actor.attemptsTo(...this.activities);
|
|
155
|
+
await origin.switchBack();
|
|
207
156
|
}
|
|
208
157
|
}
|
|
209
158
|
//# sourceMappingURL=Switch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/Switch.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"Switch.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/Switch.ts"],"names":[],"mappings":";;;AAAA,4CAAoH;AAIpH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiGG;AACH,MAAa,MAAO,SAAQ,kBAAW;IAEnC;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,CAAC,UAAkC;QACxC,OAAO,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC;IAClC,CAAC;IAED,YAAuC,UAAkC;QACrE,KAAK,CAAC,sBAAuB,UAAW,EAAE,CAAC,CAAC;QADT,eAAU,GAAV,UAAU,CAAwB;IAEzE,CAAC;IAED;;;;;;;;OAQG;IACH,GAAG,CAAC,GAAG,UAAsB;QACzB,OAAO,IAAI,0BAA0B,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACvE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,KAAuC;QACnD,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAEvD,MAAM,UAAU,CAAC,QAAQ,EAAE,CAAC;IAChC,CAAC;CACJ;AAtCD,wBAsCC;AAED;;GAEG;AACH,MAAM,0BAA2B,SAAQ,WAAI;IACzC,YACqB,UAAkC,EAClC,UAAsB;QAEvC,KAAK,CAAC,sBAAuB,UAAW,EAAE,CAAC,CAAC;QAH3B,eAAU,GAAV,UAAU,CAAwB;QAClC,eAAU,GAAV,UAAU,CAAY;IAG3C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,KAAY;QAExB,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAEvD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,QAAQ,EAAE,CAAC;QAE3C,MAAM,KAAK,CAAC,UAAU,CAClB,GAAG,IAAI,CAAC,UAAU,CACrB,CAAA;QAED,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;IAC9B,CAAC;CACJ"}
|