[Windows] Right-click Element Offset
Description
Performs a right-click action at the provided offset on the WebElement
that is found by using locator value of the given windowsObject
.
Keyword name: rightClickElementOffset
Notes on Behavior and Recording Support
- Starting from Katalon Studio 10.3.0, the offset is calculated from the center of the element (
x = width / 2
,y = height / 2
) instead of the top-left corner (x = 0
,y = 0
) as in earlier versions (e.g., KS 9.x). This update follows the W3C WebDriver specification and ensures consistency with WebUI offset-based keywords. - Katalon Studio 10.3.0 also upgrades from Selenium 3 to Selenium 4. If you use custom keywords that directly access the driver object
io.appium.java_client.windows.WindowsDriver
, you may need to update your code to comply with the Selenium 4 API. - In Windows Recorder, you can enable coordinate-based recording to interact with elements using offset-based clicks.
- When enabled,
click
andrightClick
actions are recorded asclickElementOffset
andrightClickElementOffset
, respectively. - The
clickElementOffset
action is available under the Possible Actions panel in the Recorder interface.
- When enabled,
Parameters
Parameter | Parameter Type | Required | Description |
---|---|---|---|
windowsObject | WindowsTestObject | Yes | An object describing the locator and locator strategy to find a Windows element. |
offsetX | Integer | Yes | The horizontal offset from the element’s center (KS 10.3.0+) or top-left (KS 9.x). |
offsetY | Integer | Yes | The vertical offset from the element’s center (KS 10.3.0+) or top-left (KS 9.x). |
flowControl | FailureHandling | Optional | Specify failure handling schema to determine whether the execution should be allowed to continue or stop. |
Returns
Parameter Type | Description |
---|---|
StepFailedExecution | Throws an error if the Windows element doesn't exist, or Katalon Studio could not perform a click action on the element. |
Example
Windows.startApplicationWithTitle('katalon.exe', 'Katalon Studio')
'Wait for Katalon help tab to be present'
Windows.waitForElementPresent(findWindowsObject('TabItem'), 10)
'Right click on the tab'
Windows.rightClickElementOffset(findWindowsObject('TabItem'), 107, 13)
'Switch to the context menu'
Windows.switchToApplication();
'Click on the context menu item'
Windows.click(findWindowsObject('ContextMenuItem'))
'Verify clicking on Close in context menu closes the tab'
Windows.verifyElementNotPresent(findWindowsObject('Object Repository/TabItem'), 5)
Windows.closeApplication()
'Click on OK to really close Katalon Studio'
Windows.click(findWindowsObject('Close Katalon Button'))