Skip to content

Commit df9e6ed

Browse files
fix: find element by automation name (#206)
1 parent efee24e commit df9e6ed

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

Diff for: lib/appium-driver.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export declare class AppiumDriver {
8585
* @param text
8686
* @param waitForElement
8787
*/
88-
findElementByAutomationText(automationText: string, waitForElement?: number): Promise<UIElement>;
88+
findElementByAutomationText(automationText: string, waitForElement?: number): Promise<any>;
8989
/**
9090
* Search for element by given automationText and waits until the element is displayed.
9191
* @param text

Diff for: lib/appium-driver.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,9 @@ export class AppiumDriver {
321321
*/
322322
public async findElementByAutomationText(automationText: string, waitForElement: number = this.defaultWaitTime) {
323323
if (this.isIOS) {
324-
return await this.findElementByAccessibilityId(`${automationText}`, waitForElement);
324+
return await this.findElementByAccessibilityIdIfExists(`${automationText}`, waitForElement);
325325
}
326-
return await this.findElementByXPath(this._elementHelper.getXPathByText(automationText, true), waitForElement);
326+
return await this.findElementByXPathIfExists(this._elementHelper.getXPathByText(automationText, true), waitForElement);
327327
}
328328

329329
/**
@@ -753,7 +753,7 @@ export class AppiumDriver {
753753
if (!this._args.attachToDebug) {
754754
await this._driver.quit();
755755
} else {
756-
await this._webio.detach();
756+
//await this._webio.detach();
757757
}
758758
} catch (error) {
759759
}

Diff for: lib/ui-element.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ export class UIElement {
273273

274274
const endPoint = calculateOffset(direction, y, yOffset, x, xOffset, this._webio.isIOS, false);
275275
if (direction === Direction.down) {
276-
endPoint.point.y += location.y;
276+
//endPoint.point.y += location.y;
277277
}
278278
let action = new this._wd.TouchAction(this._driver);
279279
action
@@ -292,11 +292,10 @@ export class UIElement {
292292
* @param yOffset
293293
* @param xOffset
294294
*/
295-
public async scrollTo(direction: Direction, elementToSearch, yOffset: number = 0, xOffset: number = 0) {
295+
public async scrollTo(direction: Direction, elementToSearch: () => Promise<UIElement>, yOffset: number = 0, xOffset: number = 0, retries: number = 10) {
296296
//await this._driver.execute("mobile: scroll", [{direction: 'up'}])
297297
//await this._driver.execute('mobile: scroll', { direction: direction === 0 ? "down" : "up", element: this._element.ELEMENT });
298298
let el: UIElement = null;
299-
let retries = 7;
300299
while (el === null && retries >= 0) {
301300
try {
302301
el = await elementToSearch();

0 commit comments

Comments
 (0)