ImageClick Method (TestObject)

Class

TestObject.

Action

Clicks on the specified image asset. Waits until the image is found, the specified timeout is over, or the Object resolve timeout, which you can define in the synchronization options, is over.

Syntax

TestObject.ImageClick(imageAsset,[position, occurrence, clickType, modifiers, timeout])
Variable Description
imageAsset The name of the image asset to click on. 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.

Examples

Assume you have created an image asset with the name myImage. The image in the image asset represents a UI object that you want to interact with.

  • 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("myImage")
  • 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("myImage", 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("myImage", 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.ImageClick("myImage", ClickPosition.Center, 1, ClickType.Left, ModifierKeys.None, 2000)