TouchItemXY Method (Xamarin.Forms Controls)

Applies to TestComplete 14.80, last modified on April 20, 2021

Description

The TouchItemXY action simulates a touch at the specific point within the control’s item specified by its index.

Declaration

TestObj.TouchItemXY(ItemXY)

TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
Item [in]    Required    Integer    
X [in]    Required    Integer    
Y [in]    Required    Integer    
Result None

Applies To

The method is applied to the following object:

View Mode

To view this method in the Object Browser panel and in other panels and dialogs, activate the Advanced view mode.

Parameters

The method has the following parameters:

Item

Specifies the zero-based index of the desired item.

X

Specifies the horizontal coordinate (in pixels) of the point where touching will be simulated. This coordinate is specified relatively to the top-left corner of the underlying control.

Y

Specifies the vertical coordinate (in pixels) of the point where touching will be simulated. This coordinate is specified relatively to the top-left corner of the underlying control.

Result Value

None.

Remarks

To obtain the item’s index from the item’s caption, you can use native properties of the control. For more information, see Known Issues with Xamarin.Forms applications.

Example

The following example simulates a touch at the specified point within the "Item1" button of the application’s action bar

JavaScript, JScript

function Test()
{
  // Select a mobile device
  Mobile.SetCurrent("MyMobileDevice");

  // Obtain an application
  var app = Mobile.Device().Process("SampleApp");

  // Obtain a List View
  var listview = app.XFObject("MainPage", "").XFObject("Grid", "").XFObject("ListView");

  // Simulating a touch at the specified point within the Item1
  listview.TouchItemXY(0, 5, 5)
}

Python

def Test():
  # Select a mobile device
  Mobile.SetCurrent("MyMobileDevice")

  # Obtain an application
  app = Mobile.Device().Process("SampleApp")

  # Obtain a List View
  listview = app.XFObject("MainPage", "").XFObject("Grid", "").XFObject("ListView")

  # Simulating a touch at the specified point within the Item1
  listview.TouchItemXY(0, 5, 5)

VBScript

Sub Test
  Dim app, listview

  ' Select a mobile device
  Mobile.SetCurrent("MyMobileDevice")

  ' Obtain an application
  Set app = Mobile.Device.Process("SampleApp")

  ' Obtain a List View
  Set listview = app.XFObject("MainPage", "").XFObject("Grid", "").XFObject("ListView")

  ' Simulating a touch at the specified point within the Item1
  Call listview.TouchItemXY(0, 5, 5)
End Sub

DelphiScript

function Test();
var
  app, listview;
begin
  
  // Select a mobile device
  Mobile.SetCurrent('MyMobileDevice');

  // Obtain an application
  app := Mobile.Device.Process('SampleApp');

  // Obtain a List View
  listview := app.XFObject('MainPage', '').XFObject('Grid', '').XFObject('ListView');

  // Simulating a touch at the specified point within the Item1
  listview.TouchItemXY(0, 5, 5);
end;

C++Script, C#Script

function Test()
{
  // Select a mobile device
  Mobile["SetCurrent"]("MyMobileDevice");

  // Obtain an application
  var app = Mobile["Device"]["Process"]("SampleApp");

  // Obtain a List View
  var listview = app["XFObject"]("MainPage", "")["XFObject"]("Grid", "")["XFObject"]("ListView")

  // Simulating a touch at the specified point within the Item1
  listview["TouchItemXY"](0, 5, 5)
}

See Also

TouchItem Method (Xamarin.Forms Controls)
Xamarin.Forms ListView Support
Xamarin.Forms Objects
Testing Xamarin.Forms Applications (Legacy)

Highlight search results