@@ -291,7 +291,7 @@ export class AppiumDriver {
291291 */
292292 public async findElementByXPath ( xPath : string , waitForElement : number = this . defaultWaitTime ) {
293293 const searchM = "waitForElementByXPath" ;
294- return await new UIElement ( await this . _driver . waitForElementByXPath ( xPath , waitForElement ) , this . _driver , this . _wd , this . _webio , this . _args , searchM , xPath ) ;
294+ return new UIElement ( await this . _driver . waitForElementByXPath ( xPath , waitForElement ) , this . _driver , this . _wd , this . _webio , this . _args , searchM , xPath ) ;
295295 }
296296
297297 /**
@@ -446,20 +446,18 @@ export class AppiumDriver {
446446 * @param retryCount
447447 */
448448 public async scrollTo ( direction : Direction , element : any , startPoint : Point , yOffset : number , xOffset : number = 0 , retryCount : number = 7 ) {
449- let el = null ;
450- while ( el === null && retryCount > 0 ) {
449+ let el : UIElement = null ;
450+ let isDisplayed : boolean = false ;
451+ while ( ( el === null || ! isDisplayed ) && retryCount > 0 ) {
451452 try {
452453 el = await element ( ) ;
453- if ( ! ( await el . isDisplayed ( ) ) ) {
454+ isDisplayed = await el . isDisplayed ( ) ;
455+ if ( ! isDisplayed ) {
454456 await scroll ( this . _wd , this . _driver , direction , this . _webio . isIOS , startPoint . y , startPoint . x , yOffset , xOffset , this . _args . verbose ) ;
457+ el = null ;
455458 }
456459 } catch ( error ) {
457- await scroll ( this . _wd , this . _driver , direction , this . _webio . isIOS , startPoint . y , startPoint . x , yOffset , xOffset , this . _args . verbose ) ;
458- }
459- if ( el !== null && ( await el . isDisplayed ( ) ) ) {
460- break ;
461- } else {
462- el = null ;
460+ console . log ( "scrollTo Error: " + error ) ;
463461 }
464462
465463 retryCount -- ;
@@ -750,7 +748,9 @@ export class AppiumDriver {
750748 * Hides device keyboard
751749 */
752750 public async hideDeviceKeyboard ( ) {
753- await this . _driver . hideDeviceKeyboard ( ) ;
751+ try {
752+ await this . _driver . hideDeviceKeyboard ( ) ;
753+ } catch ( error ) { }
754754 }
755755
756756 public async isKeyboardShown ( ) {
@@ -892,7 +892,7 @@ export class AppiumDriver {
892892 const element = await this . _driver . elementByXPathIfExists ( xPath , waitForElement ) ;
893893 if ( element ) {
894894 const searchMethod = "elementByXPathIfExists" ;
895- return await new UIElement ( element , this . _driver , this . _wd , this . _webio , this . _args , searchMethod , xPath ) ;
895+ return new UIElement ( element , this . _driver , this . _wd , this . _webio , this . _args , searchMethod , xPath ) ;
896896 } else {
897897 return undefined ;
898898 }
0 commit comments