AndroidDesktop Object

Applies to TestComplete 14.72, last modified on April 22, 2021

Description

The AndroidDesktop object provides information about the display of the connected Android device. To get the object in tests, use the Mobile.Device.Desktop property.

The object has the following properties and methods:

Properties
Property Description
Density Returns the density of the display (dots per inch). Integer.
Height Returns the height of the display in pixels. Integer.
Width Returns the width of the display in pixels. Integer.
Methods
Method Description
GetOrientation Returns the current orientation of the device's screen.
Picture Returns the specified rectangular area of the screen as an image.
ResetOrientation Resets the current orientation of the device's screen to a default value.
SetOrientation Sets the current orientation of the device's screen

Example

The following code gets the AndroidDesktop object and posts the value of its properties to the Test Log:

JavaScript, JScript

function GetDeskInfo()
{
  var DeskObj = Mobile.Device("MyDevice").Desktop;
  Log.Message("Width: " + DeskObj.Width);
  Log.Message("Height: " + DeskObj.Height);
  Log.Message("Density:" + DeskObj.Density);
}

Python

def GetDeskInfo():
   DeskObj = Mobile.Device("MyDevice").Desktop
   Log.Message("Width: " + VarToStr(DeskObj.Width))
   Log.Message("Height: " + VarToStr(DeskObj.Height))
   Log.Message("Density: " + VarToStr(DeskObj.Density))

VBScript

Sub GetDeskInfo
  Set DeskObj = Mobile.Device("MyDevice").Desktop
  Log.Message("Width: " & VarToStr(DeskObj.Width))
  Log.Message("Height: " & VarToStr(DeskObj.Height))
  Log.Message("Density: " & VarToStr(DeskObj.Density))
End Sub

DelphiScript

procedure GetDeskInfo();
var DeskObj;
begin
   DeskObj := Mobile.Device('MyDevice').Desktop;
   Log.Message('Width: ' + VarToStr(DeskObj.Width));
   Log.Message('Height: ' + VarToStr(DeskObj.Height));
   Log.Message('Density: ' + VarToStr(DeskObj.Density));
end;

C++Script, C#Script

function GetDeskInfo()
{
  var DeskObj = Mobile["Device"]("MyDevice")["Desktop"];
  Log["Message"]("Width: " + DeskObj["Width"]);
  Log["Message"]("Height: " + DeskObj["Height"]);
  Log["Message"]("Density:" + DeskObj["Density"]);
}

See Also

Testing Android Applications
Desktop Property (Android Testing)
iOSDesktop Object
Desktop Object

Highlight search results