Forum Discussion

harsh_chhibber's avatar
harsh_chhibber
Contributor
10 years ago

Need to capture toast message which changes frequently

Toast message displayed on the mobile screen changes frequently.

I need to capture toast message in Output(logs). 

Is there any way that I will capture the toast message(changes frequently) displayed on the screen.

4 Replies

  • Hi there,

     

    It may have been mentioned in a previous post, but you should have a look at the "WaitForControlWithText" function.

     

    Even though your text for your toast is changing, surely this is expected for you test scenario and thus you can look for it :)

     

    Have a look below, try it out and see if it works for you.

     

    //JScript

    function getToast(){
      var android_process = Aliases.Device.Process("com.android.qa");
      //Returns boolean value (true = found)
      if(android_process.WaitForControlWithText("toast_text","1000")){
        //Do something if the text was found
      }
      else {
        //Do something if the toast was not found
      }
    }
    • harsh_chhibber's avatar
      harsh_chhibber
      Contributor

      Hi 

       

      I tried below function actually when the screen comes where toast message display- Objects are not visible in Object Browser for this particular screen. It is mobile device calling screen when we dial any number. Application is dependent on this screen to make a call.

      So I am getting Object not found issue for android_process. Is there any other approach to capture toast message.

      var android_process = Aliases.Device.Process("com.android.qa");

      • altus_nel's avatar
        altus_nel
        Contributor

        Hi there,

         

        Please have a look at your Object Browser. In there you will see a "Mobile" parent node with a "Device" child node. Inside the "Device" node you will find the "Process" node. Select this node and have a look at the "ProcessName" property. This is the value you must use to address your process.

         

         

         

        var android_process = Aliases.Device.Process(<process_name>);