Description
The Mobile.Device.Desktop.Picture
method captures a screenshot of the mobile device’s desktop or of a specific screen area. The method returns a Picture
object containing the captured image.
Declaration
ProgObj.Picture(ClientX, ClientY, Width, Height)
ProgObj | An expression, variable or parameter that specifies a reference to one of the objects listed in the Applies To section | |||
ClientX | [in] | Optional | Integer | Default value: 0 |
ClientY | [in] | Optional | Integer | Default value: 0 |
Width | [in] | Optional | Integer | Default value: -1 |
Height | [in] | Optional | Integer | Default value: -1 |
Result | A Picture object |
Applies To
The method is applied to the following objects:
Parameters
The method has the following parameters:
ClientX
The horizontal (X) coordinate of the left edge of the screen area to capture. 0 (default) means the left edge of the screen.
ClientY
The vertical (Y) coordinate of the top edge of the screen area to capture. 0 (default) means the top of the screen.
Width
The width (in pixels) of the screenshot to capture. -1 (default) means the width to the right edge of the screen.
Height
The height (in pixels) of the screenshot to capture. -1 (default) means the height to the bottom of the screen.
Result Value
A Picture object containing the captured image.
Remarks
You can post the captured image to the test log to see the application state at some moment, or you can send the image to your colleague to demonstrate an issue.
TestComplete uses lossy compression for captured images, so they cannot be used for image-based testing or for image comparison.
Example
The following example captures a screenshot of the connected mobile device and posts it to the test log.
JavaScript, JScript
function Test()
{
var screenshot = Mobile.Device("MyDevice").Desktop.Picture();
Log.Picture(screenshot, "Mobile device screen");
}
Python
def Test():
screenshot = Mobile.Device("MyDevice").Desktop.Picture()
Log.Picture(screenshot, "Mobile device screen")
VBScript
Sub Test
Dim screenshot
Set screenshot = Mobile.Device("MyDevice").Desktop.Picture
Log.Picture screenshot, "Mobile device screen"
End Sub
DelphiScript
procedure Test;
var screenshot;
begin
screenshot := Mobile.Device('MyDevice').Desktop.Picture;
Log.Picture(screenshot, 'Mobile device screen');
end;
C++Script, C#Script
function Test()
{
var screenshot = Mobile["Device"]("MyDevice")["Desktop"]["Picture"]();
Log["Picture"](screenshot, "Mobile device screen");
}
See Also
Testing iOS Applications
Testing Android Applications
Picture Object
AndroidDesktop Object
iOSDesktop Object