The information below concerns legacy mobile tests that work with mobile devices connected to the local computer. For new mobile tests, we recommend using the newer cloud-compatible approach. |
Test Visualizer can automatically capture screenshots of your Android and iOS applications during test recording and test runs. You can also insert certain test operations into your tests to capture screenshots at any time you need.
Capturing Screenshots of a Mobile Device's Screen in Keyword Tests
Capturing Screenshots of a Mobile Device's Screen in Scripts
Capturing Screenshots of a Mobile Device's Screen in Keyword Tests
In keyword tests, use the Post Screenshot operation to add a screenshot of your mobile device’s screen to the test log:
-
Add the Post Screenshot operation to your test. TestComplete will show the Operation Parameters wizard.
-
On the first page of the wizard, do one of the following:
-
Enter
Aliases.device.Desktop
as the object name if you use Name Mapping orMobile.Device.Desktop
if you do not use it. -
Select the object you want to capture in the Mobile Screen window.
Click Next.
-
-
Enter the screenshot title that will appear in the test log and click Finish.
Capturing Screenshots of a Mobile Device's Screen in Scripts
In scripts, you can capture screenshots of a mobile device's screen using the Picture
method:
-
To take a screenshot, use the
Picture
method of theAliases.device.Desktop
object if you use Name Mapping or theMobile.Device.Desktop
object if you do not use it. -
To take a screenshot of a specific object, use the
Picture
method of that object.
The example below demonstrates how to capture screenshots on a mobile device:
JavaScript, JScript
function Test()
{
Mobile.SetCurrent("MyDevice");
var Picture = Mobile.Device().Desktop.Picture();
Log.Picture(Picture, "Device screenshot");
}
Python
def Test():
Mobile.SetCurrent("MyDevice");
Picture = Mobile.Device().Desktop.Picture();
Log.Picture(Picture, "Device screenshot");
VBScript
Sub Test
Dim Picture
Call Mobile.SetCurrent("MyDevice")
Set Picture = Mobile.Device.Desktop.Picture
Call Log.Picture(Picture, "Device screenshot")
End Sub
DelphiScript
procedure Test;
var Picture;
begin
Mobile.SetCurrent('MyDevice');
Picture := Mobile.Device.Desktop.Picture;
Log.Picture(Picture, 'Device screenshot');
end;
C++Script, C#Script
function Test()
{
Mobile["SetCurrent"]("MyDevice");
var Picture = Mobile["Device"]["Desktop"]["Picture"]();
Log["Picture"](Picture, "Device screenshot");
}
See Also
Picture Method (Mobile Objects)
Picture Method (Mobile Objects)
AndroidDesktop Object
iOSDesktop Object