Forum Discussion

slecault's avatar
slecault
Contributor
7 years ago
Solved

Multi Android devices vs NameMapping

I have to run the same tests on different hardware devices. I have the harware devices and a usb hub connected to my PC. 

I have mapped everything I need to run my tests.  It does run fine when one device is connected.  When a second device is running my mobile app, I get Ambiguous recognition on the "Aliases.Android.Process_myapp_abc".  I do not necessaraly want to uninstall the package after running my tests since manual testing sessions might follow.

 

Is there a way to "stop the app" on the current device?

I have tried the "close" and the "terminate" methods without success. The idea is to have only 1 of the devices running my app at a time to avoid the "ambiguous" warnings.  Note: disabling the warning does not help since it will execute the scripts on the first device it finds in windows...

 

Thanks

  • cunderw's avatar
    cunderw
    7 years ago

    If you set a default value for the project variable, you will be able to highlight on screen objects without executing the tests. 

6 Replies

  • cunderw's avatar
    cunderw
    Community Hero

    I recommend adding a property to you device mapped object for the device ID, and setting it to a project variable.

     

    You can then set the variable value at run time to run on the specific device that you would like to. 

    • slecault's avatar
      slecault
      Contributor

      I have this kind of mapping in another project for language purpose.  But the approach prevents us from highlighting from the name mapping windows because the variable only contains a value during the execution.  Having this at the very first level means nothing will be available for live validation from the name mapping.

       

      I do have a project suite variable.  First thing I do is "Mobile.SetCurrent(Project.Variables.MyMobile)", but this does not seem to affect the usage of Aliases.Android.Process_myApp.abc.

       

      • cunderw's avatar
        cunderw
        Community Hero

        If you set a default value for the project variable, you will be able to highlight on screen objects without executing the tests. 

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    > Is there a way to "stop the app" on the current device?

    Something like this might help (DelphiScript):

      Indicator.PushText(aqString.Format('Closing %s application...', aqString.Quote(strProcessName)));
      oDevice := Mobile.Device();
      strCmdOutput := oDevice.ShellExecute(aqString.Format('am force-stop %s', strProcessName));
      Log.Message(aqString.Format('%s application close result: %s',
          aqString.Quote(strProcessName), aqString.Quote(strCmdOutput)), strCmdOutput);
      Indicator.PopText();
    
    • slecault's avatar
      slecault
      Contributor

      Alex,

       

      Thanks for this code snipet, it does stop my app quite rapidly.  Would this also work under iOS ? (I have not mapped my iOS yet because of recognition issues, but it is in the plan)

       

      Thanks

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi,

         

        > Would this also work under iOS ?

        No, it will not as .ShellExecute() is a wrapper for the 'adb shell' which is Android-specific.