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?
Cybersecurity
DevOps Cloud
IT Operations Cloud
If an answer to your question is correct, click on "Verify Answer" under the "More" button. The answer will now appear with a checkmark. Please be sure to always mark answers that resolve your issue as verified. Your fellow Community members will appreciate it! Learn more.
Hi garecanbp
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
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
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