@serenity-js/webdriverio 2.32.4 → 3.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +70 -0
- package/lib/adapter/WebdriverIOFrameworkAdapter.js +1 -1
- package/lib/adapter/WebdriverIOFrameworkAdapter.js.map +1 -1
- package/lib/adapter/WebdriverIONotifier.d.ts +35 -1
- package/lib/adapter/WebdriverIONotifier.js +174 -13
- package/lib/adapter/WebdriverIONotifier.js.map +1 -1
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -3
- package/lib/index.js.map +1 -1
- package/lib/screenplay/abilities/{BrowseTheWeb.d.ts → BrowseTheWebWithWebdriverIO.d.ts} +79 -23
- package/lib/screenplay/abilities/{BrowseTheWeb.js → BrowseTheWebWithWebdriverIO.js} +160 -25
- package/lib/screenplay/abilities/BrowseTheWebWithWebdriverIO.js.map +1 -0
- package/lib/screenplay/abilities/index.d.ts +1 -1
- package/lib/screenplay/abilities/index.js +1 -1
- package/lib/screenplay/abilities/index.js.map +1 -1
- package/lib/screenplay/index.d.ts +1 -2
- package/lib/screenplay/index.js +1 -2
- package/lib/screenplay/index.js.map +1 -1
- package/lib/screenplay/models/WebdriverIOCookie.d.ts +8 -0
- package/lib/screenplay/models/WebdriverIOCookie.js +39 -0
- package/lib/screenplay/models/WebdriverIOCookie.js.map +1 -0
- package/lib/screenplay/models/WebdriverIOModalDialog.d.ts +11 -0
- package/lib/screenplay/models/WebdriverIOModalDialog.js +40 -0
- package/lib/screenplay/models/WebdriverIOModalDialog.js.map +1 -0
- package/lib/screenplay/models/WebdriverIONativeElementRoot.d.ts +2 -0
- package/lib/screenplay/{interactions/EnterBuilder.js → models/WebdriverIONativeElementRoot.js} +1 -1
- package/lib/screenplay/models/WebdriverIONativeElementRoot.js.map +1 -0
- package/lib/screenplay/models/WebdriverIOPage.d.ts +24 -0
- package/lib/screenplay/models/WebdriverIOPage.js +98 -0
- package/lib/screenplay/models/WebdriverIOPage.js.map +1 -0
- package/lib/screenplay/models/WebdriverIOPageElement.d.ts +22 -0
- package/lib/screenplay/models/WebdriverIOPageElement.js +75 -0
- package/lib/screenplay/models/WebdriverIOPageElement.js.map +1 -0
- package/lib/screenplay/models/WebdriverIOPageElements.d.ts +15 -0
- package/lib/screenplay/models/WebdriverIOPageElements.js +65 -0
- package/lib/screenplay/models/WebdriverIOPageElements.js.map +1 -0
- package/lib/screenplay/models/index.d.ts +6 -0
- package/lib/{input → screenplay/models}/index.js +6 -1
- package/lib/screenplay/models/index.js.map +1 -0
- package/package.json +18 -28
- package/src/adapter/WebdriverIOFrameworkAdapter.ts +2 -0
- package/src/adapter/WebdriverIONotifier.ts +225 -23
- package/src/index.ts +0 -3
- package/src/screenplay/abilities/{BrowseTheWeb.ts → BrowseTheWebWithWebdriverIO.ts} +200 -31
- package/src/screenplay/abilities/index.ts +1 -1
- package/src/screenplay/index.ts +1 -2
- package/src/screenplay/models/WebdriverIOCookie.ts +44 -0
- package/src/screenplay/models/WebdriverIOModalDialog.ts +45 -0
- package/src/screenplay/models/WebdriverIONativeElementRoot.ts +3 -0
- package/src/screenplay/models/WebdriverIOPage.ts +120 -0
- package/src/screenplay/models/WebdriverIOPageElement.ts +92 -0
- package/src/screenplay/models/WebdriverIOPageElements.ts +91 -0
- package/src/screenplay/models/index.ts +6 -0
- package/lib/expectations/ElementExpectation.d.ts +0 -11
- package/lib/expectations/ElementExpectation.js +0 -27
- package/lib/expectations/ElementExpectation.js.map +0 -1
- package/lib/expectations/index.d.ts +0 -6
- package/lib/expectations/index.js +0 -19
- package/lib/expectations/index.js.map +0 -1
- package/lib/expectations/isActive.d.ts +0 -15
- package/lib/expectations/isActive.js +0 -21
- package/lib/expectations/isActive.js.map +0 -1
- package/lib/expectations/isClickable.d.ts +0 -20
- package/lib/expectations/isClickable.js +0 -26
- package/lib/expectations/isClickable.js.map +0 -1
- package/lib/expectations/isEnabled.d.ts +0 -14
- package/lib/expectations/isEnabled.js +0 -20
- package/lib/expectations/isEnabled.js.map +0 -1
- package/lib/expectations/isPresent.d.ts +0 -15
- package/lib/expectations/isPresent.js +0 -21
- package/lib/expectations/isPresent.js.map +0 -1
- package/lib/expectations/isSelected.d.ts +0 -14
- package/lib/expectations/isSelected.js +0 -20
- package/lib/expectations/isSelected.js.map +0 -1
- package/lib/expectations/isVisible.d.ts +0 -14
- package/lib/expectations/isVisible.js +0 -20
- package/lib/expectations/isVisible.js.map +0 -1
- package/lib/input/Key.d.ts +0 -73
- package/lib/input/Key.js +0 -84
- 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/BrowseTheWeb.js.map +0 -1
- package/lib/screenplay/interactions/Clear.d.ts +0 -79
- package/lib/screenplay/interactions/Clear.js +0 -97
- package/lib/screenplay/interactions/Clear.js.map +0 -1
- package/lib/screenplay/interactions/Click.d.ts +0 -73
- package/lib/screenplay/interactions/Click.js +0 -84
- package/lib/screenplay/interactions/Click.js.map +0 -1
- package/lib/screenplay/interactions/DoubleClick.d.ts +0 -90
- package/lib/screenplay/interactions/DoubleClick.js +0 -101
- package/lib/screenplay/interactions/DoubleClick.js.map +0 -1
- package/lib/screenplay/interactions/Enter.d.ts +0 -73
- package/lib/screenplay/interactions/Enter.js +0 -87
- package/lib/screenplay/interactions/Enter.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/ExecuteScript.d.ts +0 -206
- package/lib/screenplay/interactions/ExecuteScript.js +0 -311
- package/lib/screenplay/interactions/ExecuteScript.js.map +0 -1
- package/lib/screenplay/interactions/Hover.d.ts +0 -78
- package/lib/screenplay/interactions/Hover.js +0 -89
- package/lib/screenplay/interactions/Hover.js.map +0 -1
- package/lib/screenplay/interactions/Navigate.d.ts +0 -141
- package/lib/screenplay/interactions/Navigate.js +0 -197
- package/lib/screenplay/interactions/Navigate.js.map +0 -1
- package/lib/screenplay/interactions/Press.d.ts +0 -84
- package/lib/screenplay/interactions/Press.js +0 -152
- package/lib/screenplay/interactions/Press.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/RightClick.d.ts +0 -89
- package/lib/screenplay/interactions/RightClick.js +0 -100
- package/lib/screenplay/interactions/RightClick.js.map +0 -1
- package/lib/screenplay/interactions/Scroll.d.ts +0 -75
- package/lib/screenplay/interactions/Scroll.js +0 -86
- package/lib/screenplay/interactions/Scroll.js.map +0 -1
- package/lib/screenplay/interactions/Wait.d.ts +0 -143
- package/lib/screenplay/interactions/Wait.js +0 -247
- package/lib/screenplay/interactions/Wait.js.map +0 -1
- package/lib/screenplay/interactions/WaitBuilder.d.ts +0 -32
- package/lib/screenplay/interactions/WaitBuilder.js +0 -3
- package/lib/screenplay/interactions/WaitBuilder.js.map +0 -1
- package/lib/screenplay/interactions/WebElementInteraction.d.ts +0 -37
- package/lib/screenplay/interactions/WebElementInteraction.js +0 -52
- package/lib/screenplay/interactions/WebElementInteraction.js.map +0 -1
- package/lib/screenplay/interactions/index.d.ts +0 -13
- package/lib/screenplay/interactions/index.js +0 -26
- package/lib/screenplay/interactions/index.js.map +0 -1
- package/lib/screenplay/questions/Attribute.d.ts +0 -82
- package/lib/screenplay/questions/Attribute.js +0 -102
- package/lib/screenplay/questions/Attribute.js.map +0 -1
- package/lib/screenplay/questions/CSSClasses.d.ts +0 -92
- package/lib/screenplay/questions/CSSClasses.js +0 -112
- package/lib/screenplay/questions/CSSClasses.js.map +0 -1
- package/lib/screenplay/questions/LastScriptExecution.d.ts +0 -14
- package/lib/screenplay/questions/LastScriptExecution.js +0 -22
- package/lib/screenplay/questions/LastScriptExecution.js.map +0 -1
- package/lib/screenplay/questions/NestedTargetBuilder.d.ts +0 -27
- package/lib/screenplay/questions/NestedTargetBuilder.js +0 -3
- package/lib/screenplay/questions/NestedTargetBuilder.js.map +0 -1
- package/lib/screenplay/questions/TargetBuilder.d.ts +0 -25
- package/lib/screenplay/questions/TargetBuilder.js +0 -3
- package/lib/screenplay/questions/TargetBuilder.js.map +0 -1
- package/lib/screenplay/questions/Text.d.ts +0 -95
- package/lib/screenplay/questions/Text.js +0 -130
- package/lib/screenplay/questions/Text.js.map +0 -1
- package/lib/screenplay/questions/Value.d.ts +0 -63
- package/lib/screenplay/questions/Value.js +0 -78
- package/lib/screenplay/questions/Value.js.map +0 -1
- package/lib/screenplay/questions/Website.d.ts +0 -21
- package/lib/screenplay/questions/Website.js +0 -31
- package/lib/screenplay/questions/Website.js.map +0 -1
- package/lib/screenplay/questions/index.d.ts +0 -10
- package/lib/screenplay/questions/index.js +0 -23
- package/lib/screenplay/questions/index.js.map +0 -1
- package/lib/screenplay/questions/lists.d.ts +0 -86
- package/lib/screenplay/questions/lists.js +0 -137
- package/lib/screenplay/questions/lists.js.map +0 -1
- package/lib/screenplay/questions/locators.d.ts +0 -196
- package/lib/screenplay/questions/locators.js +0 -219
- package/lib/screenplay/questions/locators.js.map +0 -1
- package/lib/screenplay/questions/targets.d.ts +0 -254
- package/lib/screenplay/questions/targets.js +0 -334
- package/lib/screenplay/questions/targets.js.map +0 -1
- package/lib/stage/crew/index.d.ts +0 -1
- package/lib/stage/crew/index.js +0 -14
- package/lib/stage/crew/index.js.map +0 -1
- package/lib/stage/crew/photographer/Photographer.d.ts +0 -83
- package/lib/stage/crew/photographer/Photographer.js +0 -102
- package/lib/stage/crew/photographer/Photographer.js.map +0 -1
- package/lib/stage/crew/photographer/index.d.ts +0 -2
- package/lib/stage/crew/photographer/index.js +0 -15
- package/lib/stage/crew/photographer/index.js.map +0 -1
- package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.d.ts +0 -28
- package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.js +0 -65
- package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.js.map +0 -1
- package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.d.ts +0 -18
- package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.js +0 -30
- package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.js.map +0 -1
- package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.d.ts +0 -17
- package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.js +0 -28
- package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.js.map +0 -1
- package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.d.ts +0 -19
- package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.js +0 -28
- package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.js.map +0 -1
- package/lib/stage/crew/photographer/strategies/index.d.ts +0 -4
- package/lib/stage/crew/photographer/strategies/index.js +0 -17
- package/lib/stage/crew/photographer/strategies/index.js.map +0 -1
- package/lib/stage/index.d.ts +0 -1
- package/lib/stage/index.js +0 -14
- package/lib/stage/index.js.map +0 -1
- package/src/expectations/ElementExpectation.ts +0 -31
- package/src/expectations/index.ts +0 -6
- package/src/expectations/isActive.ts +0 -21
- package/src/expectations/isClickable.ts +0 -26
- package/src/expectations/isEnabled.ts +0 -19
- package/src/expectations/isPresent.ts +0 -20
- package/src/expectations/isSelected.ts +0 -19
- package/src/expectations/isVisible.ts +0 -19
- package/src/input/Key.ts +0 -83
- package/src/input/index.ts +0 -1
- package/src/screenplay/interactions/Clear.ts +0 -102
- package/src/screenplay/interactions/Click.ts +0 -85
- package/src/screenplay/interactions/DoubleClick.ts +0 -102
- package/src/screenplay/interactions/Enter.ts +0 -93
- package/src/screenplay/interactions/EnterBuilder.ts +0 -27
- package/src/screenplay/interactions/ExecuteScript.ts +0 -344
- package/src/screenplay/interactions/Hover.ts +0 -90
- package/src/screenplay/interactions/Navigate.ts +0 -208
- package/src/screenplay/interactions/Press.ts +0 -172
- package/src/screenplay/interactions/PressBuilder.ts +0 -28
- package/src/screenplay/interactions/RightClick.ts +0 -100
- package/src/screenplay/interactions/Scroll.ts +0 -87
- package/src/screenplay/interactions/Wait.ts +0 -267
- package/src/screenplay/interactions/WaitBuilder.ts +0 -34
- package/src/screenplay/interactions/WebElementInteraction.ts +0 -56
- package/src/screenplay/interactions/index.ts +0 -13
- package/src/screenplay/questions/Attribute.ts +0 -112
- package/src/screenplay/questions/CSSClasses.ts +0 -116
- package/src/screenplay/questions/LastScriptExecution.ts +0 -21
- package/src/screenplay/questions/NestedTargetBuilder.ts +0 -30
- package/src/screenplay/questions/TargetBuilder.ts +0 -27
- package/src/screenplay/questions/Text.ts +0 -140
- package/src/screenplay/questions/Value.ts +0 -82
- package/src/screenplay/questions/Website.ts +0 -34
- package/src/screenplay/questions/index.ts +0 -10
- package/src/screenplay/questions/lists.ts +0 -161
- package/src/screenplay/questions/locators.ts +0 -254
- package/src/screenplay/questions/targets.ts +0 -401
- package/src/stage/crew/index.ts +0 -1
- package/src/stage/crew/photographer/Photographer.ts +0 -108
- package/src/stage/crew/photographer/index.ts +0 -2
- package/src/stage/crew/photographer/strategies/PhotoTakingStrategy.ts +0 -103
- package/src/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.ts +0 -28
- package/src/stage/crew/photographer/strategies/TakePhotosOfFailures.ts +0 -26
- package/src/stage/crew/photographer/strategies/TakePhotosOfInteractions.ts +0 -26
- package/src/stage/crew/photographer/strategies/index.ts +0 -4
- package/src/stage/index.ts +0 -1
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { Answerable, AnswersQuestions, Interaction, UsesAbilities } from '@serenity-js/core';
|
|
2
|
-
import { formatted } from '@serenity-js/core/lib/io';
|
|
3
|
-
import { Element } from 'webdriverio';
|
|
4
|
-
|
|
5
|
-
import { WebElementInteraction } from './WebElementInteraction';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @desc
|
|
9
|
-
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
10
|
-
* hover the mouse pointer over a given Web element.
|
|
11
|
-
*
|
|
12
|
-
* @example <caption>Example widget</caption>
|
|
13
|
-
* <a data-test="example-link"
|
|
14
|
-
* class="off"
|
|
15
|
-
* onmouseover="this.className='on';"
|
|
16
|
-
* onmouseout="this.className='off';"
|
|
17
|
-
* href="/">hover over me</a>
|
|
18
|
-
*
|
|
19
|
-
* @example <caption>Lean Page Object describing the widget</caption>
|
|
20
|
-
* import { by, Target } from '@serenity-js/webdriverio';
|
|
21
|
-
*
|
|
22
|
-
* class Example {
|
|
23
|
-
* static link = Target.the('example link')
|
|
24
|
-
* .located(by.css('[data-test="example-link"]'));
|
|
25
|
-
* }
|
|
26
|
-
*
|
|
27
|
-
* @example <caption>Hovering over an element</caption>
|
|
28
|
-
* import { actorCalled } from '@serenity-js/core';
|
|
29
|
-
* import { BrowseTheWeb, Hover, CSSClasses } from '@serenity-js/webdriverio';
|
|
30
|
-
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
31
|
-
*
|
|
32
|
-
* actorCalled('Hank')
|
|
33
|
-
* .whoCan(BrowseTheWeb.using(browser))
|
|
34
|
-
* .attemptsTo(
|
|
35
|
-
* Ensure.that(CSSClasses.of(Example.link), equals([ 'off' ])),
|
|
36
|
-
*
|
|
37
|
-
* Hover.over(Example.link),
|
|
38
|
-
* Ensure.that(CSSClasses.of(Example.link), equals([ 'on' ])),
|
|
39
|
-
* );
|
|
40
|
-
*
|
|
41
|
-
* @see {@link BrowseTheWeb}
|
|
42
|
-
* @see {@link Target}
|
|
43
|
-
* @see {@link CSSClasses}
|
|
44
|
-
* @see {@link @serenity-js/assertions~Ensure}
|
|
45
|
-
* @see {@link @serenity-js/assertions/lib/expectations~equals}
|
|
46
|
-
*
|
|
47
|
-
* @extends {WebElementInteraction}
|
|
48
|
-
*/
|
|
49
|
-
export class Hover extends WebElementInteraction {
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @desc
|
|
53
|
-
* Instantiates this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
54
|
-
*
|
|
55
|
-
* @param {Answerable<Element<'async'>>} target
|
|
56
|
-
* The element to be hovered over
|
|
57
|
-
*
|
|
58
|
-
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
59
|
-
*/
|
|
60
|
-
static over(target: Answerable<Element<'async'>>): Interaction {
|
|
61
|
-
return new Hover(target);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @param {Answerable<Element<'async'>>} target
|
|
66
|
-
* The element to be hovered over
|
|
67
|
-
*/
|
|
68
|
-
constructor(private readonly target: Answerable<Element<'async'>>) {
|
|
69
|
-
super(formatted `#actor hovers the mouse over ${ target }`);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* @desc
|
|
74
|
-
* Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
75
|
-
* perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
76
|
-
*
|
|
77
|
-
* @param {UsesAbilities & AnswersQuestions} actor
|
|
78
|
-
* An {@link @serenity-js/core/lib/screenplay/actor~Actor} to perform this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
79
|
-
*
|
|
80
|
-
* @returns {PromiseLike<void>}
|
|
81
|
-
*
|
|
82
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
83
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
|
|
84
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
85
|
-
*/
|
|
86
|
-
async performAs(actor: UsesAbilities & AnswersQuestions): Promise<void> {
|
|
87
|
-
const element = await this.resolve(actor, this.target);
|
|
88
|
-
return element.moveTo();
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import { Answerable, AnswersQuestions, Interaction, TestCompromisedError, UsesAbilities } from '@serenity-js/core';
|
|
2
|
-
import { formatted } from '@serenity-js/core/lib/io';
|
|
3
|
-
|
|
4
|
-
import { BrowseTheWeb } from '../';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @desc
|
|
8
|
-
* Allows the {@link @serenity-js/core/lib/screenplay/actor~Actor} to navigate
|
|
9
|
-
* to a specific destination, as well as back and forth in the browser history,
|
|
10
|
-
* or reload the current page.
|
|
11
|
-
*/
|
|
12
|
-
export class Navigate {
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @desc
|
|
16
|
-
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
17
|
-
* to navigate to a given URL.
|
|
18
|
-
*
|
|
19
|
-
* The URL can be:
|
|
20
|
-
* - absolute, i.e. `https://example.org/search`
|
|
21
|
-
* - relative, i.e. `/search`
|
|
22
|
-
*
|
|
23
|
-
* If the URL is relative, WebdriverIO will append it to `baseUrl` specified in
|
|
24
|
-
* the [configuration file](https://webdriver.io/docs/configurationfile/).
|
|
25
|
-
*
|
|
26
|
-
* @example <caption>wdio.conf.ts</caption>
|
|
27
|
-
* export const config = {
|
|
28
|
-
* baseUrl: 'https://example.org',
|
|
29
|
-
* // ...
|
|
30
|
-
* }
|
|
31
|
-
*
|
|
32
|
-
* @example <caption>Navigate to path relative to baseUrl</caption>
|
|
33
|
-
* import { actorCalled } from '@serenity-js/core';
|
|
34
|
-
* import { BrowseTheWeb, Navigate } from '@serenity-js/webdriverio';
|
|
35
|
-
*
|
|
36
|
-
* actorCalled('Hannu')
|
|
37
|
-
* .whoCan(BrowseTheWeb.using(browser))
|
|
38
|
-
* .attemptsTo(
|
|
39
|
-
* Navigate.to('/search'),
|
|
40
|
-
* );
|
|
41
|
-
*
|
|
42
|
-
* @example <caption>Navigate to an absolute URL (overrides baseUrl)</caption>
|
|
43
|
-
* import { actorCalled } from '@serenity-js/core';
|
|
44
|
-
* import { BrowseTheWeb, Navigate } from '@serenity-js/webdriverio';
|
|
45
|
-
*
|
|
46
|
-
* actorCalled('Hannu')
|
|
47
|
-
* .whoCan(BrowseTheWeb.using(browser))
|
|
48
|
-
* .attemptsTo(
|
|
49
|
-
* Navigate.to('https://mycompany.org/login'),
|
|
50
|
-
* );
|
|
51
|
-
*
|
|
52
|
-
* @param {Answerable<string>} url
|
|
53
|
-
* An absolute URL or path an {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
54
|
-
* should navigate to
|
|
55
|
-
*
|
|
56
|
-
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
57
|
-
*
|
|
58
|
-
* @see {@link BrowseTheWeb}
|
|
59
|
-
*/
|
|
60
|
-
static to(url: Answerable<string>): Interaction {
|
|
61
|
-
return new NavigateToUrl(url);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @desc
|
|
66
|
-
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
67
|
-
* navigate back one page in the joint session history of the current top-level browsing context.
|
|
68
|
-
*
|
|
69
|
-
* @example <caption>Navigate to path relative to baseUrl</caption>
|
|
70
|
-
* import { actorCalled } from '@serenity-js/core';
|
|
71
|
-
* import { Ensure, endsWith } from '@serenity-js/assertions';
|
|
72
|
-
* import { BrowseTheWeb, Navigate } from '@serenity-js/webdriverio';
|
|
73
|
-
*
|
|
74
|
-
* actorCalled('Hannu')
|
|
75
|
-
* .whoCan(BrowseTheWeb.using(browser))
|
|
76
|
-
* .attemptsTo(
|
|
77
|
-
* Navigate.to('/first'),
|
|
78
|
-
* Navigate.to('/second'),
|
|
79
|
-
*
|
|
80
|
-
* Navigate.back(),
|
|
81
|
-
*
|
|
82
|
-
* Ensure.that(Website.url(), endsWith('/first')),
|
|
83
|
-
* );
|
|
84
|
-
*
|
|
85
|
-
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
86
|
-
*
|
|
87
|
-
* @see https://webdriver.io/docs/api/webdriver/#back
|
|
88
|
-
* @see {@link BrowseTheWeb}
|
|
89
|
-
* @see {@link @serenity-js/assertions~Ensure}
|
|
90
|
-
* @see {@link @serenity-js/assertions/lib/expectations~endsWith}
|
|
91
|
-
*/
|
|
92
|
-
static back(): Interaction {
|
|
93
|
-
return Interaction.where(`#actor navigates back in the browser history`, actor =>
|
|
94
|
-
BrowseTheWeb.as(actor).browser.back(),
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* @desc
|
|
100
|
-
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
101
|
-
* navigate forward one page in the session history.
|
|
102
|
-
*
|
|
103
|
-
* @example <caption>Navigate to path relative to baseUrl</caption>
|
|
104
|
-
* import { actorCalled } from '@serenity-js/core';
|
|
105
|
-
* import { Ensure, endsWith } from '@serenity-js/assertions';
|
|
106
|
-
* import { BrowseTheWeb, Navigate } from '@serenity-js/webdriverio';
|
|
107
|
-
*
|
|
108
|
-
* actorCalled('Hannu')
|
|
109
|
-
* .whoCan(BrowseTheWeb.using(browser))
|
|
110
|
-
* .attemptsTo(
|
|
111
|
-
* Navigate.to('/first'),
|
|
112
|
-
* Navigate.to('/second'),
|
|
113
|
-
*
|
|
114
|
-
* Navigate.back(),
|
|
115
|
-
* Navigate.forward(),
|
|
116
|
-
*
|
|
117
|
-
* Ensure.that(Website.url(), endsWith('/second')),
|
|
118
|
-
* );
|
|
119
|
-
*
|
|
120
|
-
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
121
|
-
*
|
|
122
|
-
* @see {@link BrowseTheWeb}
|
|
123
|
-
* @see {@link @serenity-js/assertions~Ensure}
|
|
124
|
-
* @see {@link @serenity-js/assertions/lib/expectations~endsWith}
|
|
125
|
-
* @see https://webdriver.io/docs/api/webdriver/#forward
|
|
126
|
-
*/
|
|
127
|
-
static forward(): Interaction {
|
|
128
|
-
return Interaction.where(`#actor navigates forward in the browser history`, actor =>
|
|
129
|
-
BrowseTheWeb.as(actor).browser.forward(),
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* @desc
|
|
135
|
-
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
136
|
-
* reload the current page.
|
|
137
|
-
*
|
|
138
|
-
* @example <caption>Navigate to path relative to baseUrl</caption>
|
|
139
|
-
* import { actorCalled } from '@serenity-js/core';
|
|
140
|
-
* import { Ensure, endsWith } from '@serenity-js/assertions';
|
|
141
|
-
* import { Navigate, BrowseTheWeb, DeleteCookies } from '@serenity-js/webdriverio';
|
|
142
|
-
*
|
|
143
|
-
* actorCalled('Hannu')
|
|
144
|
-
* .whoCan(BrowseTheWeb.using(browser))
|
|
145
|
-
* .attemptsTo(
|
|
146
|
-
* Navigate.to('/login'),
|
|
147
|
-
* DeleteCookies.called('session_id'),
|
|
148
|
-
* Navigate.reloadPage(),
|
|
149
|
-
* );
|
|
150
|
-
*
|
|
151
|
-
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
152
|
-
*
|
|
153
|
-
* @see {@link BrowseTheWeb}
|
|
154
|
-
* @see {@link DeleteCookies}
|
|
155
|
-
* @see {@link @serenity-js/assertions~Ensure}
|
|
156
|
-
* @see {@link @serenity-js/assertions/lib/expectations~endsWith}
|
|
157
|
-
*/
|
|
158
|
-
static reloadPage(): Interaction {
|
|
159
|
-
return Interaction.where(`#actor reloads the page`, actor =>
|
|
160
|
-
BrowseTheWeb.as(actor).browser.refresh(),
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* @package
|
|
167
|
-
*/
|
|
168
|
-
class NavigateToUrl extends Interaction {
|
|
169
|
-
constructor(private readonly url: Answerable<string>) {
|
|
170
|
-
super();
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* @desc
|
|
175
|
-
* Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
176
|
-
* perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
177
|
-
*
|
|
178
|
-
* @param {UsesAbilities & AnswersQuestions} actor
|
|
179
|
-
* An {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
180
|
-
* to perform this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
181
|
-
*
|
|
182
|
-
* @returns {PromiseLike<void>}
|
|
183
|
-
*
|
|
184
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
185
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
|
|
186
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
187
|
-
*/
|
|
188
|
-
performAs(actor: UsesAbilities & AnswersQuestions): PromiseLike<void> {
|
|
189
|
-
return actor.answer(this.url)
|
|
190
|
-
.then(url =>
|
|
191
|
-
BrowseTheWeb.as(actor)
|
|
192
|
-
.get(url)
|
|
193
|
-
.catch(error => {
|
|
194
|
-
throw new TestCompromisedError(`Couldn't navigate to ${ url }`, error);
|
|
195
|
-
})
|
|
196
|
-
)
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* @desc
|
|
201
|
-
* Generates a description to be used when reporting this {@link @serenity-js/core/lib/screenplay~Activity}.
|
|
202
|
-
*
|
|
203
|
-
* @returns {string}
|
|
204
|
-
*/
|
|
205
|
-
toString(): string {
|
|
206
|
-
return formatted `#actor navigates to ${ this.url }`;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { Activity, Answerable, AnswersQuestions, Interaction, Question, UsesAbilities } from '@serenity-js/core';
|
|
2
|
-
import { formatted } from '@serenity-js/core/lib/io';
|
|
3
|
-
import { Element } from 'webdriverio';
|
|
4
|
-
|
|
5
|
-
import { Key } from '../../input';
|
|
6
|
-
import { BrowseTheWeb } from '../abilities';
|
|
7
|
-
import { PressBuilder } from './PressBuilder';
|
|
8
|
-
import { WebElementInteraction } from './WebElementInteraction';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @desc
|
|
12
|
-
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
13
|
-
* send a key press or a sequence of keys to a Web element.
|
|
14
|
-
*
|
|
15
|
-
* *Please note*: On macOS, some keyboard shortcuts might not work with the [`devtools` protocol](https://webdriver.io/docs/automationProtocols/#devtools-protocol).
|
|
16
|
-
*
|
|
17
|
-
* For example:
|
|
18
|
-
* - to *copy*, instead of `Meta+C`, use `Control+Insert`
|
|
19
|
-
* - to *cut*, instead of `Meta+X`, use `Control+Delete`
|
|
20
|
-
* - to *paste*, instead of `Meta+V`, use `Shift+Insert`
|
|
21
|
-
*
|
|
22
|
-
* @example <caption>Example widget</caption>
|
|
23
|
-
* <form>
|
|
24
|
-
* <input type="text" name="example" id="example" />
|
|
25
|
-
* </form>
|
|
26
|
-
*
|
|
27
|
-
* @example <caption>Lean Page Object describing the widget</caption>
|
|
28
|
-
* import { by, Target } from '@serenity-js/webdriverio';
|
|
29
|
-
*
|
|
30
|
-
* class Form {
|
|
31
|
-
* static exampleInput = Target.the('example input')
|
|
32
|
-
* .located(by.id('example'));
|
|
33
|
-
* }
|
|
34
|
-
*
|
|
35
|
-
* @example <caption>Pressing keys</caption>
|
|
36
|
-
* import { actorCalled } from '@serenity-js/core';
|
|
37
|
-
* import { BrowseTheWeb, Key, Press, Value } from '@serenity-js/webdriverio';
|
|
38
|
-
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
39
|
-
*
|
|
40
|
-
* actorCalled('Priyanka')
|
|
41
|
-
* .whoCan(BrowseTheWeb.using(browser))
|
|
42
|
-
* .attemptsTo(
|
|
43
|
-
* Press.the('H', 'i', '!', Key.ENTER).in(Form.exampleInput),
|
|
44
|
-
* Ensure.that(Value.of(Form.exampleInput), equals('Hi!')),
|
|
45
|
-
* );
|
|
46
|
-
*
|
|
47
|
-
* @see {@link Key}
|
|
48
|
-
* @see {@link BrowseTheWeb}
|
|
49
|
-
* @see {@link Target}
|
|
50
|
-
* @see {@link @serenity-js/assertions~Ensure}
|
|
51
|
-
* @see {@link @serenity-js/assertions/lib/expectations~equals}
|
|
52
|
-
*
|
|
53
|
-
* @extends {WebElementInteraction}
|
|
54
|
-
*/
|
|
55
|
-
export class Press extends WebElementInteraction {
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* @desc
|
|
59
|
-
* Instantiates this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
60
|
-
*
|
|
61
|
-
* @param {...keys: Array<Answerable<Key | string | Key[] | string[]>>} keys
|
|
62
|
-
* A sequence of one or more keys to press
|
|
63
|
-
*
|
|
64
|
-
* @returns {PressBuilder}
|
|
65
|
-
*/
|
|
66
|
-
static the(...keys: Array<Answerable<Key | string | Key[] | string[]>>): Activity & PressBuilder {
|
|
67
|
-
return new Press(KeySequence.of(keys));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
in(field: Answerable<Element<'async'>> /* | Question<AlertPromise> | AlertPromise */): Interaction {
|
|
71
|
-
return new PressKeyInField(this.keys, field)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @param {Answerable<Array<Key | string>>} keys
|
|
76
|
-
* A sequence of one or more keys to press
|
|
77
|
-
*/
|
|
78
|
-
constructor(
|
|
79
|
-
private readonly keys: Answerable<Array<Key | string>>
|
|
80
|
-
) {
|
|
81
|
-
super(formatted `#actor presses ${ keys }`);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* @desc
|
|
86
|
-
* Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
87
|
-
* perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
88
|
-
*
|
|
89
|
-
* @param {UsesAbilities & AnswersQuestions} actor
|
|
90
|
-
* An {@link @serenity-js/core/lib/screenplay/actor~Actor} to perform this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
91
|
-
*
|
|
92
|
-
* @returns {PromiseLike<void>}
|
|
93
|
-
*
|
|
94
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
95
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
|
|
96
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
97
|
-
*/
|
|
98
|
-
async performAs(actor: UsesAbilities & AnswersQuestions): Promise<void> {
|
|
99
|
-
const keys = await actor.answer(this.keys);
|
|
100
|
-
|
|
101
|
-
return BrowseTheWeb.as(actor).sendKeys(keys);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
class PressKeyInField extends WebElementInteraction {
|
|
106
|
-
/**
|
|
107
|
-
* @param {Answerable<Array<Key | string>>} keys
|
|
108
|
-
* A sequence of one or more keys to press
|
|
109
|
-
*
|
|
110
|
-
* @param {Answerable<Element<'async'>>} field
|
|
111
|
-
* Web element to send the keys to
|
|
112
|
-
*/
|
|
113
|
-
constructor(
|
|
114
|
-
private readonly keys: Answerable<Array<Key | string>>,
|
|
115
|
-
private readonly field: Answerable<Element<'async'>> /* todo | Question<AlertPromise> | AlertPromise */,
|
|
116
|
-
) {
|
|
117
|
-
super(formatted `#actor presses ${ keys } in ${ field }`);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
async performAs(actor: UsesAbilities & AnswersQuestions): Promise<void> {
|
|
121
|
-
const field = await this.resolve(actor, this.field);
|
|
122
|
-
const keys = await actor.answer(this.keys);
|
|
123
|
-
|
|
124
|
-
await BrowseTheWeb.as(actor).browser.execute(
|
|
125
|
-
/* istanbul ignore next */
|
|
126
|
-
function focus(element: any) { // todo: fix type
|
|
127
|
-
element.focus();
|
|
128
|
-
},
|
|
129
|
-
field,
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
return BrowseTheWeb.as(actor).sendKeys(keys);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* @package
|
|
138
|
-
*/
|
|
139
|
-
class KeySequence extends Question<Promise<Array<Key | string>>> {
|
|
140
|
-
static of(keys: Array<Answerable<Key | string | Key[] | string[]>>) {
|
|
141
|
-
return new KeySequence(keys);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
constructor(private readonly keys: Array<Answerable<Key | string | Key[] | string[]>>) {
|
|
145
|
-
super(KeySequence.describe(keys));
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<Array<string | Key>> {
|
|
149
|
-
return Promise.all(
|
|
150
|
-
this.keys.map(part => actor.answer(part))
|
|
151
|
-
).then(keys => keys.flat().filter(key => !! key))
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
private static describe(keys: Array<Answerable<Key | string | Key[] | string[]>>): string {
|
|
155
|
-
const prefix = keys.length === 1 ? 'key' : 'keys';
|
|
156
|
-
|
|
157
|
-
const description = keys.reduce((acc, key, index) => {
|
|
158
|
-
const separator = Key.isKey(key) && key.isModifier
|
|
159
|
-
? '-'
|
|
160
|
-
: acc.separator;
|
|
161
|
-
|
|
162
|
-
return {
|
|
163
|
-
description: index === 0
|
|
164
|
-
? `${ key }`
|
|
165
|
-
: `${ acc.description }${acc.separator}${ key }`,
|
|
166
|
-
separator,
|
|
167
|
-
}
|
|
168
|
-
}, { description: '', separator: ', ' }).description;
|
|
169
|
-
|
|
170
|
-
return `${ prefix } ${ description }`;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Answerable } from '@serenity-js/core';
|
|
2
|
-
import { Interaction } from '@serenity-js/core/lib/screenplay';
|
|
3
|
-
import { Element } from 'webdriverio';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @desc
|
|
7
|
-
* Fluent interface to make the instantiation of
|
|
8
|
-
* the {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
9
|
-
* to {@link Press} more readable.
|
|
10
|
-
*
|
|
11
|
-
* @see {@link Press}
|
|
12
|
-
*
|
|
13
|
-
* @interface
|
|
14
|
-
*/
|
|
15
|
-
export interface PressBuilder {
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @desc
|
|
19
|
-
* Instantiates an {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
20
|
-
* to {@link Press}.
|
|
21
|
-
*
|
|
22
|
-
* @param {Question<ElementFinder> | ElementFinder | Question<AlertPromise> | AlertPromise} field
|
|
23
|
-
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
24
|
-
*
|
|
25
|
-
* @see {@link Target}
|
|
26
|
-
*/
|
|
27
|
-
in: (field: Answerable<Element<'async'>> /* | Question<AlertPromise> | AlertPromise */) => Interaction;
|
|
28
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { Answerable, AnswersQuestions, Interaction, UsesAbilities } from '@serenity-js/core';
|
|
2
|
-
import { formatted } from '@serenity-js/core/lib/io';
|
|
3
|
-
import { Element } from 'webdriverio';
|
|
4
|
-
|
|
5
|
-
import { WebElementInteraction } from './WebElementInteraction';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @desc
|
|
9
|
-
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
10
|
-
* perfom a right click on a given Web element.
|
|
11
|
-
*
|
|
12
|
-
* This is typically used to open a [custom context menu](https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event)
|
|
13
|
-
* on a given Web element, since it's not possible to interact with the standard context menu offered by your browser
|
|
14
|
-
*
|
|
15
|
-
* @example <caption>Example widget</caption>
|
|
16
|
-
* <form>
|
|
17
|
-
* <input type="text" id="field"
|
|
18
|
-
* oncontextmenu="showMenu(); return false;" />
|
|
19
|
-
*
|
|
20
|
-
* <div id="context-menu" style="display:none">
|
|
21
|
-
* Custom context menu
|
|
22
|
-
* </div>
|
|
23
|
-
* </form>
|
|
24
|
-
*
|
|
25
|
-
* <script>
|
|
26
|
-
* function showMenu() {
|
|
27
|
-
* document.getElementById("context-menu").style.display = 'block';
|
|
28
|
-
* }
|
|
29
|
-
* </script>
|
|
30
|
-
*
|
|
31
|
-
* @example <caption>Lean Page Object describing the widget</caption>
|
|
32
|
-
* import { by, Target } from '@serenity-js/webdriverio';
|
|
33
|
-
*
|
|
34
|
-
* class Form {
|
|
35
|
-
* static exampleInput = Target.the('example input')
|
|
36
|
-
* .located(by.id('example'));
|
|
37
|
-
* static exampleContextMenu = Target.the('example context menu')
|
|
38
|
-
* .located(by.id('context-menu'));
|
|
39
|
-
* }
|
|
40
|
-
*
|
|
41
|
-
* @example <caption>Right-click on an element</caption>
|
|
42
|
-
* import { actorCalled } from '@serenity-js/core';
|
|
43
|
-
* import { BrowseTheWeb, RightClick, isVisible } from '@serenity-js/webdriverio';
|
|
44
|
-
* import { Ensure } from '@serenity-js/assertions';
|
|
45
|
-
*
|
|
46
|
-
* actorCalled('Chloé')
|
|
47
|
-
* .whoCan(BrowseTheWeb.using(browser))
|
|
48
|
-
* .attemptsTo(
|
|
49
|
-
* RightClick.on(Form.exampleInput),
|
|
50
|
-
* Ensure.that(Form.exampleContextMenu, isVisible()),
|
|
51
|
-
* );
|
|
52
|
-
*
|
|
53
|
-
* @see {@link BrowseTheWeb}
|
|
54
|
-
* @see {@link Target}
|
|
55
|
-
* @see {@link @serenity-js/assertions~Ensure}
|
|
56
|
-
* @see {@link isVisible}
|
|
57
|
-
*
|
|
58
|
-
* @extends {WebElementInteraction}
|
|
59
|
-
*/
|
|
60
|
-
export class RightClick extends WebElementInteraction {
|
|
61
|
-
/**
|
|
62
|
-
* @desc
|
|
63
|
-
* Instantiates this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
64
|
-
*
|
|
65
|
-
* @param {Answerable<Element<'async'>>} target
|
|
66
|
-
* The element to be right-clicked on
|
|
67
|
-
*
|
|
68
|
-
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
69
|
-
*/
|
|
70
|
-
static on(target: Answerable<Element<'async'>>): Interaction {
|
|
71
|
-
return new RightClick(target);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @param {Answerable<Element<'async'>>} target
|
|
76
|
-
* The element to be right-clicked on
|
|
77
|
-
*/
|
|
78
|
-
constructor(private readonly target: Answerable<Element<'async'>>) {
|
|
79
|
-
super(formatted `#actor right-clicks on ${ target }`);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* @desc
|
|
84
|
-
* Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
85
|
-
* perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
86
|
-
*
|
|
87
|
-
* @param {UsesAbilities & AnswersQuestions} actor
|
|
88
|
-
* An {@link @serenity-js/core/lib/screenplay/actor~Actor} to perform this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
89
|
-
*
|
|
90
|
-
* @returns {PromiseLike<void>}
|
|
91
|
-
*
|
|
92
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
93
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
|
|
94
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
95
|
-
*/
|
|
96
|
-
async performAs(actor: UsesAbilities & AnswersQuestions): Promise<void> {
|
|
97
|
-
const element = await this.resolve(actor, this.target);
|
|
98
|
-
return element.click({ button: 'right' });
|
|
99
|
-
}
|
|
100
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { Answerable, AnswersQuestions, Interaction, UsesAbilities } from '@serenity-js/core';
|
|
2
|
-
import { formatted } from '@serenity-js/core/lib/io';
|
|
3
|
-
import { Element } from 'webdriverio';
|
|
4
|
-
|
|
5
|
-
import { WebElementInteraction } from './WebElementInteraction';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @desc
|
|
9
|
-
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
10
|
-
* scroll until a given Web element comes into view.
|
|
11
|
-
*
|
|
12
|
-
* @example <caption>Example widget</caption>
|
|
13
|
-
* <!--
|
|
14
|
-
* an element somewhere at the bottom of the page,
|
|
15
|
-
* outside of the visible area
|
|
16
|
-
* -->
|
|
17
|
-
* <input type="submit" id="submit" />
|
|
18
|
-
*
|
|
19
|
-
* @example <caption>Lean Page Object describing the widget</caption>
|
|
20
|
-
* import { by, Target } from '@serenity-js/webdriverio';
|
|
21
|
-
*
|
|
22
|
-
* class Form {
|
|
23
|
-
* static submitButton = Target.the('submit button')
|
|
24
|
-
* .located(by.id('submit'));
|
|
25
|
-
* }
|
|
26
|
-
*
|
|
27
|
-
* @example <caption>Scrolling to element</caption>
|
|
28
|
-
* import { actorCalled } from '@serenity-js/core';
|
|
29
|
-
* import { Ensure } from '@serenity-js/assertions';
|
|
30
|
-
* import { BrowseTheWeb, Scroll, isVisible } from '@serenity-js/webdriverio';
|
|
31
|
-
*
|
|
32
|
-
* actorCalled('Sara')
|
|
33
|
-
* .whoCan(BrowseTheWeb.using(browser))
|
|
34
|
-
* .attemptsTo(
|
|
35
|
-
* Scroll.to(Form.submitButton),
|
|
36
|
-
* Ensure.that(Form.submitButton, isVisible()),
|
|
37
|
-
* );
|
|
38
|
-
*
|
|
39
|
-
* @see {@link BrowseTheWeb}
|
|
40
|
-
* @see {@link Target}
|
|
41
|
-
* @see {@link isVisible}
|
|
42
|
-
* @see {@link @serenity-js/assertions~Ensure}
|
|
43
|
-
*
|
|
44
|
-
* @extends {@serenity-js/core/lib/screenplay~Interaction}
|
|
45
|
-
*/
|
|
46
|
-
export class Scroll extends WebElementInteraction {
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @desc
|
|
50
|
-
* Instantiates this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
51
|
-
*
|
|
52
|
-
* @param {Answerable<Element<'async'>>} target
|
|
53
|
-
* The element to be scrolled to
|
|
54
|
-
*
|
|
55
|
-
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
56
|
-
*/
|
|
57
|
-
static to(target: Answerable<Element<'async'>>) : Interaction {
|
|
58
|
-
return new Scroll(target);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* @param {Answerable<Element<'async'>>} target
|
|
63
|
-
* The element to be scrolled to
|
|
64
|
-
*/
|
|
65
|
-
constructor(private readonly target: Answerable<Element<'async'>>) {
|
|
66
|
-
super(formatted `#actor scrolls to ${ target }`);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* @desc
|
|
71
|
-
* Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
72
|
-
* perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
73
|
-
*
|
|
74
|
-
* @param {UsesAbilities & AnswersQuestions} actor
|
|
75
|
-
* An {@link @serenity-js/core/lib/screenplay/actor~Actor} to perform this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
76
|
-
*
|
|
77
|
-
* @returns {PromiseLike<void>}
|
|
78
|
-
*
|
|
79
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
80
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
|
|
81
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
82
|
-
*/
|
|
83
|
-
async performAs(actor: UsesAbilities & AnswersQuestions): Promise<void> {
|
|
84
|
-
const element = await this.resolve(actor, this.target);
|
|
85
|
-
return element.scrollIntoView();
|
|
86
|
-
}
|
|
87
|
-
}
|