@cloudscape-design/browser-test-tools 3.0.109 → 3.0.110

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.
@@ -2,9 +2,14 @@ export interface ScrollPosition {
2
2
  top: number;
3
3
  left: number;
4
4
  }
5
- export declare function scrollAction(action: 'scrollToOffset' | 'scrollToRight' | 'scrollToBottom', selector: string, offset?: {
6
- top: number;
7
- left: number;
5
+ export type ScrollAction = 'scrollToOffset' | 'scrollToRight' | 'scrollToBottom';
6
+ export declare function scrollAction({ action, selector, offset, }: {
7
+ action: ScrollAction;
8
+ selector: string;
9
+ offset?: {
10
+ top: number;
11
+ left: number;
12
+ };
8
13
  }): void;
9
14
  export declare function getElementScrollPosition(selector: string): ScrollPosition;
10
15
  export declare function windowScrollTo(top: number, left: number): void;
@@ -4,7 +4,7 @@ exports.scrollAction = scrollAction;
4
4
  exports.getElementScrollPosition = getElementScrollPosition;
5
5
  exports.windowScrollTo = windowScrollTo;
6
6
  exports.getWindowScrollPosition = getWindowScrollPosition;
7
- function scrollAction(action, selector, offset) {
7
+ function scrollAction({ action, selector, offset, }) {
8
8
  const element = document.querySelector(selector);
9
9
  if (!element) {
10
10
  throw new Error('Element ' + selector + ' has not been found at the page');
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "b9fd896e34b30c9180c55ec16157e83a275ad7f9"
2
+ "commit": "ebe2433b8e05128aa8c4d8b955b38a2d28966e5e"
3
3
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudscape-design/browser-test-tools",
3
- "version": "3.0.109",
3
+ "version": "3.0.110",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/cloudscape-design/browser-test-tools.git"
@@ -19,17 +19,17 @@
19
19
  "internal"
20
20
  ],
21
21
  "dependencies": {
22
- "@aws-sdk/client-device-farm": "^3.623.0",
22
+ "@aws-sdk/client-device-farm": "^3.996.0",
23
23
  "@types/pngjs": "^6.0.4",
24
- "@wdio/globals": "^9.7.0",
25
- "@wdio/types": "^9.6.3",
24
+ "@wdio/globals": "^9.23.0",
25
+ "@wdio/types": "^9.24.0",
26
26
  "get-stream": "^6.0.1",
27
27
  "lodash": "^4.17.23",
28
28
  "p-retry": "^4.6.2",
29
29
  "pixelmatch": "^5.3.0",
30
30
  "pngjs": "^6.0.0",
31
31
  "wait-on": "^8.0.3",
32
- "webdriverio": "^9.7.0"
32
+ "webdriverio": "^9.24.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/lodash": "^4.14.186",
@@ -34,7 +34,7 @@ export default class BasePageObject {
34
34
  isDisplayed(selector: string): Promise<boolean>;
35
35
  isDisplayedInViewport(selector: string): Promise<boolean>;
36
36
  isClickable(selector: string): Promise<boolean>;
37
- getElementAttribute(selector: string, attributeName: string): Promise<string>;
37
+ getElementAttribute(selector: string, attributeName: string): Promise<string | null>;
38
38
  getElementProperty(selector: string, propertyName: string): Promise<unknown>;
39
39
  getElementsCount(selector: string): Promise<number>;
40
40
  getFocusedElementText(): Promise<string>;
@@ -114,8 +114,11 @@ class BasePageObject {
114
114
  await element.dragAndDrop({ x: xOffset, y: yOffset });
115
115
  }
116
116
  async getValue(selector) {
117
- const element = await this.browser.$(selector);
118
- return element.getValue();
117
+ const element = this.browser.$(selector);
118
+ const value = await element.getValue();
119
+ // getValue should return a Promise<string>, but the latest Webdriver is providing a wrong type for it,
120
+ // so we need to cast it until https://github.com/webdriverio/webdriverio/issues/15097 is resolved.
121
+ return value;
119
122
  }
120
123
  async setValue(selector, value) {
121
124
  const element = await this.browser.$(selector);
@@ -135,7 +138,8 @@ class BasePageObject {
135
138
  return this.browser.execute(browser_scripts_1.getElementScrollPosition, selector);
136
139
  }
137
140
  async elementScrollTo(selector, { top = 0, left = 0 }) {
138
- await this.browser.execute(browser_scripts_1.scrollAction, 'scrollToOffset', selector, { top, left });
141
+ const action = 'scrollToOffset';
142
+ await this.browser.execute(browser_scripts_1.scrollAction, { action, selector, offset: { top, left } });
139
143
  }
140
144
  async waitForVisible(selector, shouldDisplay = true, timeout) {
141
145
  await this.browser.waitUntil(async () => {
@@ -202,8 +206,9 @@ class BasePageObject {
202
206
  return elements.length;
203
207
  }
204
208
  async getFocusedElementText() {
205
- const activeNode = await this.browser.getActiveElement();
206
- const element = await this.browser.$(activeNode);
209
+ // Cast to Selector as workaround for https://github.com/webdriverio/webdriverio/issues/15118
210
+ const activeNode = (await this.browser.getActiveElement());
211
+ const element = this.browser.$(activeNode);
207
212
  return element.getText();
208
213
  }
209
214
  async getBoundingBox(selector) {
@@ -18,10 +18,12 @@ class ScreenshotPageObject extends base_1.default {
18
18
  return this.keys('Tab');
19
19
  }
20
20
  async scrollToBottom(selector) {
21
- await this.browser.execute(browser_scripts_1.scrollAction, 'scrollToBottom', selector);
21
+ const action = 'scrollToBottom';
22
+ await this.browser.execute(browser_scripts_1.scrollAction, { action, selector });
22
23
  }
23
24
  async scrollToRight(selector) {
24
- await this.browser.execute(browser_scripts_1.scrollAction, 'scrollToRight', selector);
25
+ const action = 'scrollToRight';
26
+ await this.browser.execute(browser_scripts_1.scrollAction, { action, selector });
25
27
  }
26
28
  async fullPageScreenshot() {
27
29
  // preserve scroll position in order to avoid side effects after screenshot taking