This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to Close Mobile App and re-launch it in the middle of test

I have a scenario that needed me to close Mobile App and re-launch it in the middle of test. Is it possible to do it in Silk Test Workbench with .NET script?

  • Verified Answer

    +1  

    Hi

    You should be able to simply call the CloseApp() method to close the app:

    _devce.MobileDevice("//MobileDevice").CloseApp()

    To relaunch the app, you will need to script a MobileBaseState:

    dim baseState as New MobileBaseState("deviceName=Pixel 2;platformName=Android;appPackage=my.app;appActivity=.MainActivity")
    baseState.Execute()

    -Robert

  • 0 in reply to   

    could we set the base state value to get automatically the value from the App Config?

  • 0   in reply to 

    Unfortunately we cannot retrieve the App Config details from a Workbench script at runtime.

    You should however be able to get the various device details after you intially connect to the device and construct a connection string. For example:

            Dim deviceId As String = _desktop.MobileDevice("Device").DeviceId
            Dim osType As MobileOperatingSystem = _desktop.MobileDevice("Device").OperatingSystem
            Dim osVersion As String = _desktop.MobileDevice("Device").OsVersion

    -Robert

  • 0 in reply to   

    Hi Robert,

    Is it possible to retrieve the AppPackage?

  • Suggested Answer

    0   in reply to 

    You can dynamically invoke the Appium driver methods to get this information:

                Console.WriteLine(_desktop.MobileDevice("//MobileDevice").Invoke("getCurrentPackage"))
                Console.WriteLine(_desktop.MobileDevice("//MobileDevice").Invoke("currentActivity"))

    I hope that helps.

    -Robert