ImageClickFile Method (TestObject)

Class

TestObject.

Action

Clicks on the specified image.

Syntax

C#
testObject.ImageClickFile(imageFile, [position, occurrence, clickType, modifiers, timeout]);
VB
testObject.ImageClickFile(imageFile, [position, occurrence, clickType, modifiers, timeout])
Variable Description
imageFile An absolute path to an image file of one of the following types:
  • .bmp
  • .png
Note: This path can be either absolute or relative to the working directory during playback.
STRING.
position Optional: The coordinates at which to click. The coordinates are relative to the upper-left corner of the image. To click in the center of the image use ClickPosition.Center. The default value is the center of the image. Point.
occurrence Optional: The occurrence of the image that should be clicked, if there are multiple occurrences. The first occurrence is 1. The default value is 1. Integer.
clickType Optional: The desired mouse action. The default value is left click. ClickType .
modifiers Optional: The modifier keys, Alt, Shift, or Ctrl, to press while clicking. Default: No modifier keys are used. ModifierKeys.
timeout Optional: The maximum time in milliseconds to wait for the image to appear. If the timeout is not specified, the ImageClick method waits for the image to appear until the Object resolve timeout is over. Integer.

C# Examples

Assume you have an image with the name myImage.png in the directory C:\temp.

  • To search for the image in the application under test and to click in the center of the found image, you can use the following code:
     control.ImageClickFile("C:\temp\myImage.png");
  • To click on a specific position inside the image, instead of in the center of the image, you can use the following code:
     control.ImageClickFile("C:\temp\myImage.png", new Point(10, 20));
  • To right-click in the center of the second occurrence of the image in the application under test, you can use the following code:
    control.ImageClickFile("C:\temp\myImage.png", ClickPosition.Center, 2, ClickType.Right);
  • To wait two seconds for the image to appear and to click in the center of the found image, you can use the following code:
    control.ImageClickFile("C:\temp\myImage.png", ClickPosition.Center, 1, ClickType.Left, ModifierKeys.None, 2000);

Visual Basic Examples

Assume you have an image with the name myImage.png in the directory C:\temp.

  • To search for the image in the application under test and to click in the center of the found image, you can use the following code:
     control.ImageClick("C:\temp\myImage.png")
  • To click on a specific position inside the image, instead of in the center of the image, you can use the following code:
     control.ImageClick("C:\temp\myImage.png", New Point(10, 20))
  • To right-click in the center of the second occurrence of the image in the application under test, you can use the following code:
    control.ImageClick("C:\temp\myImage.png", ClickPosition.Center, 2, ClickType.Right)
  • To wait two seconds for the image to appear and to click in the center of the found image, you can use the following code:
    control.ImageClickFile("C:\temp\myImage.png", ClickPosition.Center, 1, ClickType.Left, ModifierKeys.None, 2000)