Skip to content

Commit 517ee59

Browse files
fix: sctollTo
1 parent 75ee5c0 commit 517ee59

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/appium-driver.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -521,13 +521,15 @@ export class AppiumDriver {
521521
while ((el === null || !isDisplayed) && retryCount > 0) {
522522
try {
523523
el = await element();
524-
isDisplayed = await el.isDisplayed();
524+
isDisplayed = el && await el.isDisplayed();
525525
if (!isDisplayed) {
526-
await scroll(this._wd, this._driver, direction, this._webio.isIOS, startPoint.y, startPoint.x, offsetPoint.x, offsetPoint.y);
526+
await scroll(this._wd, this._driver, direction, this._webio.isIOS, startPoint.y, startPoint.x, offsetPoint.y, offsetPoint.x);
527527
el = null;
528528
}
529529
} catch (error) {
530530
console.log("scrollTo Error: " + error);
531+
await scroll(this._wd, this._driver, direction, this._webio.isIOS, startPoint.y, startPoint.x, offsetPoint.y, offsetPoint.x);
532+
el = null;
531533
}
532534

533535
retryCount--;

lib/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ export function calculateOffset(direction, y: number, yOffset: number, x: number
393393
duration = Math.abs(yOffset) * speed;
394394
}
395395
if (direction === Direction.up) {
396-
yEnd = direction * Math.abs((Math.abs(yOffset) + y));
396+
yEnd = Math.abs((Math.abs(y - yOffset)));
397397
duration = Math.abs(yOffset) * speed;
398398
}
399399

0 commit comments

Comments
 (0)