X Property

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

Description

The PointObj.X property lets you set and get the current horizontal coordinate of the pixel relative to the screen.

Declaration

PointObj.X

Read-Write Property Integer
PointObj An expression, variable or parameter that specifies a reference to a Point object

Applies To

The property is applied to the following object:

Property Value

The integer number that denotes the current horizontal coordinate of the pixel represented by the PointObj object.

Example

The following example demonstrates how you can use the Point object. It creates a Point object that specifies the control-relative coordinates and uses these coordinates to simulate a click on a control. After that, it creates another Point object that contains the screen-relative coordinates of the performed click.

JavaScript, JScript

function PointSample()
{

  var ScreenPoint, ControlPoint, TestBtn;

  …

  // Obtains the test control
  TestBtn = Aliases.SampleApplication.MainForm.btn;

  // Creates a Point object and specifies the control-related coordinates
  ControlPoint = Utils.Point;
  ControlPoint.X = 3;
  ControlPoint.Y = 5;
  // Simulates a click on the control at the specified point
  TestBtn.Click(ControlPoint.X, ControlPoint.Y);

  // Creates a Point object that holds the screen-related coordinates
  ScreenPoint = TestBtn.WindowToScreen(ControlPoint.X, ControlPoint.Y);
  …

}

Python

def PointSample():
  # ...
  # Obtains the test control
  TestBtn = Aliases.SampleApplication.MainForm.btn
  # Creates a Point object and specifies the control-related coordinates
  ControlPoint = Utils.Point
  ControlPoint.X = 3
  ControlPoint.Y = 5
  # Simulates a click on the control at the specified point
  TestBtn.Click(ControlPoint.X, ControlPoint.Y)
  # Creates a Point object that holds the screen-related coordinates
  ScreenPoint = TestBtn.WindowToScreen(ControlPoint.X, ControlPoint.Y);
  # ...

VBScript

Sub PointSample

  Dim ScreenPoint, ControlPoint, TestBtn

  …

  ' Obtains the test control
  Set TestBtn = Aliases.SampleApplication.MainForm.btn

  ' Creates a Point object and specifies the control-related coordinates
  Set ControlPoint = Utils.Point
  ControlPoint.X = 3
  ControlPoint.Y = 5
  ' Simulates a click on the control at the specified point
  Call TestBtn.Click(ControlPoint.X, ControlPoint.Y)

  ' Creates a Point object that holds the screen-related coordinates
  Set ScreenPoint = TestBtn.WindowToScreen(ControlPoint.X, ControlPoint.Y)
  …

End Sub

DelphiScript

procedure PointSample();
var ScreenPoint, ControlPoint, TestBtn, Text, SourceText;

begin

  …

  // Obtains the test control
  TestBtn := Aliases.SampleApplication.MainForm.btn;

  // Creates a Point object and specifies the control-related coordinates
  ControlPoint := Utils.Point;
  ControlPoint.X := 3;
  ControlPoint.Y := 5;
  // Simulates a click on the control at the specified point
  TestBtn.Click(ControlPoint.X, ControlPoint.Y);

  // Creates a Point object that holds the screen-related coordinates
  ScreenPoint := TestBtn.WindowToScreen(ControlPoint.X, ControlPoint.Y);
  …

end;

C++Script, C#Script

function PointSample()
{

  var ScreenPoint, ControlPoint, TestBtn;

  …

  // Obtains the test control
  TestBtn = Aliases["SampleApplication"]["MainForm"]["btn"];

  // Creates a Point object and specifies the control-related coordinates
  ControlPoint = Utils["Point"];
  ControlPoint["X"] = 3;
  ControlPoint["Y"] = 5;
  // Simulates a click on the control at the specified point
  TestBtn["Click"](ControlPoint["X"], ControlPoint["Y"]);

  // Creates a Point object that holds the screen-related coordinates
  ScreenPoint = TestBtn["WindowToScreen"](ControlPoint["X"], ControlPoint["Y"]);
  …

}

See Also

Y Property

Highlight search results