Description
Use the ResetTestedApp
method to restore the tested application running on a mobile device to its initial state.
On iOS devices running in the BitBar device cloud, the method can reset the tested application only if the application’s bundle ID has been specified when opening a testing session.
Declaration
ApplicationManagerObj.ResetTestedApp()
ApplicationManagerObj | An expression, variable or parameter that specifies a reference to an ApplicationManager object | |||
Result | None |
Applies To
The method is applied to the following object:
Result Value
None.
Example
The code below shows how to get the ApplicationManager
object and how to use it to start, reset, and then stop the tested application for which the testing session is opened on the mobile device:
Note: For the example to work correctly, your project must be connected to the BitBar cloud and the bitbar_app
capability must specify a correct application ID in the BitBar file storage. If you use an iOS device, the bundleId
capability must also be specified for the testing session. See Project Properties > Device Cloud > Mobile.
JavaScript
{
// Connect to a mobile device
var capabilities = {
"platformName": "ANDROID",
"bitbar_target": "android",
"bitbar_findDevice": "false",
"bitbar_device": "Google Pixel 3a Android 10",
"deviceName": "Google Pixel 3a Android 10",
"automationName": "UiAutomator2",
"bitbar_app": "1234"
};
var server = "https://appium.bitbar.com/wd/hub/";
Mobile.ConnectDevice(server, capabilities);
var appManager = Mobile.Device().ApplicationManager;
// Launch the tested application
appManager.LaunchTestedApp();
// Simulate user actions
// …
// Switch the tested application to the background mode
appManager.BackgroundTestedApp();
// …
// Reset and restart the tested application
appManager.ResetTestedApp();
// …
// Close the tested application and stop the testing session
appManager.CloseTestedApp();
}
JScript
{
// Connect to a mobile device
var capabilities = "{\"platformName\":\"ANDROID\",\"bitbar_target\":\"android\",\"bitbar_findDevice\":false,\"bitbar_device\":\"Google Pixel 3a Android 10\",\"deviceName\":\"Google Pixel 3a Android 10\",\"automationName\":\"UiAutomator2\",\"bitbar_app\":\"1234\"}";
var server = "https://appium.bitbar.com/wd/hub/";
Mobile.ConnectDevice(server, capabilities);
var appManager = Mobile.Device().ApplicationManager;
// Launch the tested application
appManager.LaunchTestedApp();
// Simulate user actions
// …
// Switch the tested application to the background mode
appManager.BackgroundTestedApp();
// …
// Reset and restart the tested application
appManager.ResetTestedApp();
// …
// Close the tested application and stop the testing session
appManager.CloseTestedApp();
}
Python
def Test():
# Connect to a mobile device
capabilities = {
"platformName": "ANDROID",
"bitbar_target": "android",
"bitbar_findDevice": "false",
"bitbar_device": "Google Pixel 3a Android 10",
"deviceName": "Google Pixel 3a Android 10",
"automationName": "UiAutomator2",
"bitbar_app": "1234"
}
server = "https://appium.bitbar.com/wd/hub/"
Mobile.ConnectDevice(server, capabilities)
appManager = Mobile.Device().ApplicationManager
# Launch the tested application
appManager.LaunchTestedApp
# Simulate user actions
# ...
# Switch the tested application to the background mode
appManager.BackgroundTestedApp
# ...
# Reset and restart the tested appication
appManager.ResetTestedApp
# ...
# Close the tested application and stop the testing session
appManager.CloseTestedApp
VBScript
Sub Test()
' Connect to a mobile device
capabilities = "{""platformName"":""ANDROID"",""bitbar_target"":""android"",""bitbar_findDevice"":false,""bitbar_device"":""Google Pixel 3a Android 10"",""deviceName"":""Google Pixel 3a Android 10"",""automationName"":""UiAutomator2"",""bitbar_app"":""1234""}"
server = "https://appium.bitbar.com/wd/hub/"
Call Mobile.ConnectDevice(server, capabilities)
Set appManager = Mobile.Device().ApplicationManager
' Launch the tested application
appManager.LaunchTestedApp
' Simulate user actions
' …
' Switch the tested application to the background mode
appManager.BackgroundTestedApp
' …
' Reset and restart the tested application
appManager.ResetTestedApp
' …
' Close the tested application and stop the testing session
appManager.CloseTestedApp
End Sub
DelphiScript
var capabilities, server, appManager;
begin
// Connect to a mobile device
capabilities := '{"platformName":"ANDROID","bitbar_target":"android","bitbar_findDevice":false,"bitbar_device":"Google Pixel 3a Android 10","deviceName":"Google Pixel 3a Android 10","automationName":"UiAutomator2","bitbar_app":"1234"}';
server := 'https://appium.bitbar.com/wd/hub/';
Mobile.ConnectDevice(server, capabilities);
appManager := Mobile.Device().ApplicationManager;
// Launch the tested application
appManager.LaunchTestedApp();
// Simulate user actions
// …
// Switch the tested application to the background mode
appManager.BackgroundTestedApp();
// …
// Reset and restart the tested application
appManager.ResetTestedApp();
// …
// Close the tested application and stop the testing session
appManager.CloseTestedApp();
end;
C++Script, C#Script
{
// Connect to a mobile device
var capabilities = "{\"platformName\":\"ANDROID\",\"bitbar_target\":\"android\",\"bitbar_findDevice\":false,\"bitbar_device\":\"Google Pixel 3a Android 10\",\"deviceName\":\"Google Pixel 3a Android 10\",\"automationName\":\"UiAutomator2\",\"bitbar_app\":\"1234\"}";
var server = "https://appium.bitbar.com/wd/hub/";
Mobile["ConnectDevice"](server, capabilities);
var appManager = Mobile["Device"]()["ApplicationManager"];
// Launch the tested application
appManager["LaunchTestedApp"]();
// Simulate user actions
// …
// Switch the tested application to the background mode
appManager["BackgroundTestedApp"]();
// …
// Reset and restart the tested application
appManager["ResetTestedApp"]();
// …
// Close the tested application and stop the testing session
appManager["CloseTestedApp"]();
}