@serenity-js/web 3.9.0 → 3.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/lib/screenplay/models/Page.d.ts.map +1 -1
  3. package/lib/screenplay/models/Page.js.map +1 -1
  4. package/lib/screenplay/models/PageElement.d.ts +3 -3
  5. package/lib/screenplay/models/PageElement.d.ts.map +1 -1
  6. package/lib/screenplay/models/PageElement.js.map +1 -1
  7. package/lib/screenplay/models/PageElements.d.ts +6 -16
  8. package/lib/screenplay/models/PageElements.d.ts.map +1 -1
  9. package/lib/screenplay/models/PageElements.js +5 -60
  10. package/lib/screenplay/models/PageElements.js.map +1 -1
  11. package/lib/screenplay/models/PageElementsLocator.d.ts +19 -0
  12. package/lib/screenplay/models/PageElementsLocator.d.ts.map +1 -0
  13. package/lib/screenplay/models/PageElementsLocator.js +41 -0
  14. package/lib/screenplay/models/PageElementsLocator.js.map +1 -0
  15. package/lib/screenplay/models/index.d.ts +1 -0
  16. package/lib/screenplay/models/index.d.ts.map +1 -1
  17. package/lib/screenplay/models/index.js +1 -0
  18. package/lib/screenplay/models/index.js.map +1 -1
  19. package/lib/screenplay/questions/Attribute.d.ts +1 -1
  20. package/lib/screenplay/questions/Attribute.d.ts.map +1 -1
  21. package/lib/screenplay/questions/CssClasses.d.ts +2 -31
  22. package/lib/screenplay/questions/CssClasses.d.ts.map +1 -1
  23. package/lib/screenplay/questions/CssClasses.js +11 -48
  24. package/lib/screenplay/questions/CssClasses.js.map +1 -1
  25. package/lib/screenplay/questions/Text.d.ts +2 -1
  26. package/lib/screenplay/questions/Text.d.ts.map +1 -1
  27. package/lib/screenplay/questions/Text.js +11 -71
  28. package/lib/screenplay/questions/Text.js.map +1 -1
  29. package/lib/screenplay/questions/Value.d.ts +2 -30
  30. package/lib/screenplay/questions/Value.d.ts.map +1 -1
  31. package/lib/screenplay/questions/Value.js +5 -41
  32. package/lib/screenplay/questions/Value.js.map +1 -1
  33. package/package.json +4 -4
  34. package/src/screenplay/models/Page.ts +1 -0
  35. package/src/screenplay/models/PageElement.ts +5 -5
  36. package/src/screenplay/models/PageElements.ts +8 -91
  37. package/src/screenplay/models/PageElementsLocator.ts +57 -0
  38. package/src/screenplay/models/index.ts +1 -0
  39. package/src/screenplay/questions/Attribute.ts +1 -1
  40. package/src/screenplay/questions/CssClasses.ts +17 -58
  41. package/src/screenplay/questions/Text.ts +22 -100
  42. package/src/screenplay/questions/Value.ts +10 -51
@@ -1,4 +1,4 @@
1
- import type { AnswersQuestions, MetaQuestion, MetaQuestionAdapter,QuestionAdapter, UsesAbilities } from '@serenity-js/core';
1
+ import type { Answerable,MetaQuestionAdapter, QuestionAdapter } from '@serenity-js/core';
2
2
  import { d, Question } from '@serenity-js/core';
3
3
 
4
4
  import { PageElement } from '../models';
@@ -57,11 +57,7 @@ import { PageElement } from '../models';
57
57
  *
58
58
  * @group Questions
59
59
  */
60
- export class Value
61
- extends Question<Promise<string>>
62
- implements MetaQuestion<PageElement, string>
63
- {
64
- private subject: string;
60
+ export class Value {
65
61
 
66
62
  /**
67
63
  * Instantiates a {@apilink Question} that uses
@@ -74,50 +70,13 @@ export class Value
74
70
  * @param pageElement
75
71
  */
76
72
  static of(pageElement: QuestionAdapter<PageElement> | PageElement): MetaQuestionAdapter<PageElement, string> {
77
- return Question.createAdapter(new Value(pageElement)) as MetaQuestionAdapter<PageElement, string>;
78
- }
79
-
80
- protected constructor(private readonly element: QuestionAdapter<PageElement> | PageElement) {
81
- super();
82
- this.subject = d`the value of ${ element }`;
83
- }
84
-
85
- /**
86
- * Instantiates a {@apilink Question} that uses
87
- * the {@apilink Actor|actor's} {@apilink Ability|ability} to {@apilink BrowseTheWeb} to retrieve
88
- * the `value` attribute of a given {@apilink PageElement}
89
- * located within the `parent` element.
90
- *
91
- * #### Learn more
92
- * - {@apilink MetaQuestion}
93
- *
94
- * @param parent
95
- */
96
- of(parent: QuestionAdapter<PageElement> | PageElement): Question<Promise<string>> {
97
- return new Value(PageElement.of(this.element, parent));
98
- }
99
-
100
- /**
101
- * @inheritDoc
102
- */
103
- async answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<string> {
104
- const element = await actor.answer(this.element);
105
-
106
- return element.value();
107
- }
108
-
109
- /**
110
- * @inheritDoc
111
- */
112
- describedAs(subject: string): this {
113
- this.subject = subject;
114
- return this;
115
- }
116
-
117
- /**
118
- * @inheritDoc
119
- */
120
- toString(): string {
121
- return this.subject;
73
+ return Question.about(d`the value of ${ pageElement }`,
74
+ async actor => {
75
+ const element = await actor.answer(pageElement);
76
+ return element.value();
77
+ },
78
+ (parent: Answerable<PageElement>) =>
79
+ Value.of(PageElement.of(pageElement, parent))
80
+ );
122
81
  }
123
82
  }