Skip to content

Commit 8e8922f

Browse files
Zdravko BranzovZdravko Branzov
authored andcommitted
fix: respect provided offset parameters when scrolling vertical and horizontal
1 parent 517ee59 commit 8e8922f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/ui-element.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,18 @@ export class UIElement {
293293
const size = await this.size();
294294

295295
if (direction === Direction.down || direction === Direction.up) {
296+
if (xOffset > 0) {
297+
location.x += xOffset;
298+
}
296299
if (yOffset === 0) {
297300
yOffset = location.y + size.height - 5;
298301
}
299302
}
300303

301304
if (direction === Direction.left || direction === Direction.right) {
305+
if (yOffset > 0) {
306+
location.y += yOffset;
307+
}
302308
if (xOffset === 0) {
303309
xOffset = location.x + size.width - 5;
304310
}
@@ -330,7 +336,7 @@ export class UIElement {
330336
while (el === null && retries >= 0) {
331337
try {
332338
el = await elementToSearch();
333-
if (!el || el === null || !(await el.isDisplayed())) {
339+
if (!el || el === null || !(el && await el.isDisplayed())) {
334340
el = null;
335341
await this.scroll(direction, yOffset, xOffset);
336342
}
@@ -370,7 +376,7 @@ export class UIElement {
370376
if (shouldClearText) {
371377
await this.adbDeleteText(adbDeleteCharsCount);
372378
}
373-
text = text.replace(" ","%s");
379+
text = text.replace(" ", "%s");
374380
await this.click();
375381
await adbShellCommand(this._driver, "input", ["text", text]);
376382
} else {

0 commit comments

Comments
 (0)