@applitools/driver 1.11.7 → 1.11.9
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/dist/element.js +11 -16
- package/dist/helper-android.js +0 -4
- package/package.json +1 -1
- package/types/spec-driver.d.ts +2 -2
package/dist/element.js
CHANGED
|
@@ -53,12 +53,12 @@ class Element {
|
|
|
53
53
|
if (specUtils.isSimpleCommonSelector(this._selector)) {
|
|
54
54
|
this._commonSelector = this._selector;
|
|
55
55
|
}
|
|
56
|
-
else if (utils.types.isString(this._selector)) {
|
|
57
|
-
this._commonSelector = { selector: this._selector };
|
|
58
|
-
}
|
|
59
56
|
else if (this._selector && this._spec.untransformSelector) {
|
|
60
57
|
this._commonSelector = this._spec.untransformSelector(this._spec.transformSelector(this._selector));
|
|
61
58
|
}
|
|
59
|
+
else if (utils.types.isString(this._selector)) {
|
|
60
|
+
this._commonSelector = { selector: this._selector };
|
|
61
|
+
}
|
|
62
62
|
}
|
|
63
63
|
get target() {
|
|
64
64
|
return this._target;
|
|
@@ -338,7 +338,7 @@ class Element {
|
|
|
338
338
|
}
|
|
339
339
|
else {
|
|
340
340
|
this._logger.log('Extracting text of native element with selector', this.selector);
|
|
341
|
-
return this._spec.getElementText(this.
|
|
341
|
+
return this._spec.getElementText(this.context.target, this.target);
|
|
342
342
|
}
|
|
343
343
|
});
|
|
344
344
|
this._logger.log('Extracted element text', text);
|
|
@@ -392,6 +392,7 @@ class Element {
|
|
|
392
392
|
async scrollTo(offset, options) {
|
|
393
393
|
return this.withRefresh(async () => {
|
|
394
394
|
var _a;
|
|
395
|
+
this._logger.log(`Scrolling to offset (${offset.x}, ${offset.y}) element with selector`, this.selector);
|
|
395
396
|
offset = utils.geometry.round({ x: Math.max(offset.x, 0), y: Math.max(offset.y, 0) });
|
|
396
397
|
if (this.driver.isWeb) {
|
|
397
398
|
let actualOffset = await this.context.execute(snippets.scrollTo, [this, offset]);
|
|
@@ -483,7 +484,7 @@ class Element {
|
|
|
483
484
|
xRemaining -= xRight - xLeft;
|
|
484
485
|
}
|
|
485
486
|
// vertical scrolling
|
|
486
|
-
const yPadding = Math.max(Math.floor(effectiveRegion.height * 0.
|
|
487
|
+
const yPadding = Math.max(Math.floor(effectiveRegion.height * 0.08), touchPadding + 3);
|
|
487
488
|
const xTrack = Math.floor(effectiveRegion.x + 5); // a little bit off left border
|
|
488
489
|
const yBottom = effectiveRegion.y + effectiveRegion.height - yPadding;
|
|
489
490
|
const yDirection = remainingOffset.y > 0 ? 'down' : 'up';
|
|
@@ -545,7 +546,7 @@ class Element {
|
|
|
545
546
|
}
|
|
546
547
|
}
|
|
547
548
|
else if (actions.length > 0) {
|
|
548
|
-
await this._spec.performAction(this.driver.target,
|
|
549
|
+
await this._spec.performAction(this.driver.target, actions.flat());
|
|
549
550
|
}
|
|
550
551
|
const actualScrollableRegion = await this.getClientRegion();
|
|
551
552
|
this._state.scrollOffset = utils.geometry.offsetNegative(requiredOffset, {
|
|
@@ -595,17 +596,13 @@ class Element {
|
|
|
595
596
|
}
|
|
596
597
|
async type(value) {
|
|
597
598
|
this._logger.log(`Typing text "${value}" in element with selector`, this.selector);
|
|
598
|
-
await this._spec.
|
|
599
|
+
await this._spec.setElementText(this.context.target, this.target, value);
|
|
599
600
|
}
|
|
600
601
|
async preserveState() {
|
|
601
|
-
if (this.driver.isNative)
|
|
602
|
-
return;
|
|
603
|
-
// TODO create single js snippet
|
|
604
602
|
const scrollOffset = await this.getScrollOffset();
|
|
605
|
-
const transforms =
|
|
606
|
-
this,
|
|
607
|
-
|
|
608
|
-
]);
|
|
603
|
+
const transforms = this.driver.isWeb
|
|
604
|
+
? await this.context.execute(snippets.getElementStyleProperties, [this, ['transform', '-webkit-transform']])
|
|
605
|
+
: null;
|
|
609
606
|
if (!utils.types.has(this._state, ['scrollOffset', 'transforms'])) {
|
|
610
607
|
this._state.scrollOffset = scrollOffset;
|
|
611
608
|
this._state.transforms = transforms;
|
|
@@ -613,8 +610,6 @@ class Element {
|
|
|
613
610
|
return { scrollOffset, transforms };
|
|
614
611
|
}
|
|
615
612
|
async restoreState(state = this._state) {
|
|
616
|
-
if (this.driver.isNative)
|
|
617
|
-
return;
|
|
618
613
|
if (state.scrollOffset)
|
|
619
614
|
await this.scrollTo(state.scrollOffset);
|
|
620
615
|
if (state.transforms)
|
package/dist/helper-android.js
CHANGED
|
@@ -75,9 +75,6 @@ class HelperAndroid {
|
|
|
75
75
|
return resourceId.split('/')[1];
|
|
76
76
|
}
|
|
77
77
|
async _command(command) {
|
|
78
|
-
// clean the input before passing value there could
|
|
79
|
-
// be a left over from previous async calls
|
|
80
|
-
await this._input.type('');
|
|
81
78
|
await this._input.type(command);
|
|
82
79
|
await this._input.click();
|
|
83
80
|
let text = await this._input.getText();
|
|
@@ -96,7 +93,6 @@ class HelperAndroid {
|
|
|
96
93
|
this._logger.warn(`Helper library didn't provide a response for async command (${command}) during ${timeout}ms`);
|
|
97
94
|
text = null;
|
|
98
95
|
}
|
|
99
|
-
await this._input.type('');
|
|
100
96
|
return text;
|
|
101
97
|
}
|
|
102
98
|
async getContentRegion(element, options) {
|
package/package.json
CHANGED
package/types/spec-driver.d.ts
CHANGED
|
@@ -61,6 +61,8 @@ export interface SpecDriver<TDriver, TContext, TElement, TSelector> {
|
|
|
61
61
|
findElement(context: TContext, selector: TSelector, parent?: TElement): Promise<TElement | null>;
|
|
62
62
|
findElements(context: TContext, selector: TSelector, parent?: TElement): Promise<TElement[]>;
|
|
63
63
|
waitForSelector?(context: TContext, selector: TSelector, parent?: TElement, options?: WaitOptions): Promise<TElement | null>;
|
|
64
|
+
setElementText?(context: TContext, element: TElement, text: string): Promise<void>;
|
|
65
|
+
getElementText?(context: TContext, element: TElement): Promise<string>;
|
|
64
66
|
setWindowSize?(driver: TDriver, size: Size): Promise<void>;
|
|
65
67
|
getWindowSize?(driver: TDriver): Promise<Size>;
|
|
66
68
|
setViewportSize?(driver: TDriver, size: Size): Promise<void>;
|
|
@@ -72,7 +74,6 @@ export interface SpecDriver<TDriver, TContext, TElement, TSelector> {
|
|
|
72
74
|
getUrl(driver: TDriver): Promise<string>;
|
|
73
75
|
takeScreenshot(driver: TDriver): Promise<Buffer | string>;
|
|
74
76
|
click?(context: TContext, element: TElement | TSelector): Promise<void>;
|
|
75
|
-
type?(context: TContext, element: TElement, value: string): Promise<void>;
|
|
76
77
|
visit?(driver: TDriver, url: string): Promise<void>;
|
|
77
78
|
getOrientation?(driver: TDriver): Promise<ScreenOrientation>;
|
|
78
79
|
setOrientation?(driver: TDriver, orientation: ScreenOrientation): Promise<void>;
|
|
@@ -94,7 +95,6 @@ export interface SpecDriver<TDriver, TContext, TElement, TSelector> {
|
|
|
94
95
|
}>;
|
|
95
96
|
getElementRegion?(driver: TDriver, element: TElement): Promise<Region>;
|
|
96
97
|
getElementAttribute?(driver: TDriver, element: TElement, attr: string): Promise<string>;
|
|
97
|
-
getElementText?(driver: TDriver, element: TElement): Promise<string>;
|
|
98
98
|
performAction?(driver: TDriver, steps: any[]): Promise<void>;
|
|
99
99
|
getCurrentWorld?(driver: TDriver): Promise<string>;
|
|
100
100
|
getWorlds?(driver: TDriver): Promise<string[]>;
|