@@ -320,6 +320,18 @@ export class AppiumDriver {
320320 * @param waitForElement
321321 */
322322 public async findElementByAutomationText ( automationText : string , waitForElement : number = this . defaultWaitTime ) {
323+ if ( this . isIOS ) {
324+ return await this . findElementByAccessibilityId ( `${ automationText } ` , waitForElement ) ;
325+ }
326+ return await this . findElementByXPath ( this . _elementHelper . getXPathByText ( automationText , true ) , waitForElement ) ;
327+ }
328+
329+ /**
330+ * Search for element by given automationText. Searches only for exact string.
331+ * @param text
332+ * @param waitForElement
333+ */
334+ public async findElementByAutomationTextIfExists ( automationText : string , waitForElement : number = this . defaultWaitTime ) {
323335 if ( this . isIOS ) {
324336 return await this . findElementByAccessibilityIdIfExists ( `${ automationText } ` , waitForElement ) ;
325337 }
@@ -334,12 +346,12 @@ export class AppiumDriver {
334346 public async waitForElement ( automationText : string , waitInMilliseconds : number = this . defaultWaitTime ) : Promise < UIElement > {
335347 let element ;
336348 try {
337- element = await this . findElementByAutomationText ( automationText , 100 ) ;
349+ element = await this . findElementByAutomationTextIfExists ( automationText , 100 ) ;
338350 } catch ( error ) { }
339351 const startTime = Date . now ( ) ;
340352 while ( ( ! element || ! ( await element . isDisplayed ( ) ) ) && Date . now ( ) - startTime <= waitInMilliseconds ) {
341353 try {
342- element = await this . findElementByAutomationText ( automationText , 100 ) ;
354+ element = await this . findElementByAutomationTextIfExists ( automationText , 100 ) ;
343355 } catch ( error ) { }
344356 }
345357
@@ -730,7 +742,7 @@ export class AppiumDriver {
730742 * @param time in minutes
731743 */
732744 public async backgroundApp ( minutes : number ) {
733- console . log ( "Sending the currently active app to the background ..." ) ;
745+ logInfo ( "Sending the currently active app to the background ..." ) ;
734746 await this . _driver . backgroundApp ( minutes ) ;
735747 }
736748
@@ -756,20 +768,23 @@ export class AppiumDriver {
756768 }
757769
758770 public async quit ( ) {
759- console . log ( "Killing driver" ) ;
760771 if ( this . _recordVideoInfo && this . _recordVideoInfo [ 'videoRecordingProcess' ] ) {
761772 this . _recordVideoInfo [ 'videoRecordingProcess' ] . kill ( "SIGINT" ) ;
762773 }
763774 try {
764775 if ( ! this . _args . attachToDebug ) {
776+ console . log ( "Killing driver..." ) ;
765777 await this . _driver . quit ( ) ;
778+ this . _isAlive = false ;
779+ console . log ( "Driver is dead!" ) ;
766780 } else {
767781 //await this._webio.detach();
768782 }
769783 } catch ( error ) {
784+ if ( this . _args . verbose ) {
785+ console . dir ( error ) ;
786+ }
770787 }
771- this . _isAlive = false ;
772- console . log ( "Driver is dead" ) ;
773788 }
774789
775790 private static async applyAdditionalSettings ( args ) {
@@ -817,13 +832,16 @@ export class AppiumDriver {
817832
818833 private static configureLogging ( driver , verbose ) {
819834 driver . on ( "status" , function ( info ) {
820- log ( info . cyan , verbose ) ;
835+ log ( info , verbose ) ;
836+ } ) ;
837+ driver . on ( "quit" , function ( info ) {
838+ console . log ( "QUIT: " , info ) ;
821839 } ) ;
822840 driver . on ( "command" , function ( meth , path , data ) {
823- log ( " > " + meth . yellow + path . grey + " " + ( data || "" ) , verbose ) ;
841+ log ( " > " + meth + " " + path + " " + ( data || "" ) , verbose ) ;
824842 } ) ;
825843 driver . on ( "http" , function ( meth , path , data ) {
826- log ( " > " + meth . magenta + path + " " + ( data || "" ) . grey , verbose ) ;
844+ log ( " > " + meth + " " + path + " " + ( data || "" ) , verbose ) ;
827845 } ) ;
828846 } ;
829847
@@ -945,4 +963,4 @@ export class AppiumDriver {
945963
946964 return new UIElement ( searchResult , this . _driver , this . _wd , this . _webio , this . _args , "elementByImage" , imageAsBase64 ) ;
947965 }
948- }
966+ }
0 commit comments