Trying to click Windows Object via Xpath?

I am attempting to use xpath to click on desired buttons via a windows application.

I don’t have any problems clicking on them as a direct call to the button as stored in the object repository.

The application has multiple panels like the image below, and I want to be able to select the panel and button to click using the xpath. I’m doing something wrong and would like to correct that.

f1

I was trying: Windows.click(findWindowsObject(By.xpath(“//Window//Pane[1]//Tab[1]//TabItem[1]//Pane[1]//Pane[1]//Button[11]”)))

The goal is to replace the last Pane and Button int with a variable once I can get the xpath syntax figured out.

The error I’m getting for that is:
Test Cases/Test FAILED.
Reason:
groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject() is applicable for argument types: (org.openqa.selenium.By$ByXPath) values: [By.xpath: //Window//Pane[1]//Tab[1]//TabItem[1]//Pane[1]//Pane[1]//Button[11]]
Possible solutions: findWindowsObject(java.lang.String), findWindowsObject(java.lang.String, java.util.Map)
at preset.Conf.SelectStation(Conf.groovy:132)
at preset.Conf$SelectStation.call(Unknown Source)
at Test.run(Test:15)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)

Hi,

As mentioned here, Possible solutions: findWindowsObject(java.lang.String), findWindowsObject(java.lang.String, java.util.Map)

You get the error because you put the object By.xpath... inside findWindowsObject() instead of a Java String. Follow this format: findWindowsObject(‘{your test object}’, [(‘{variable}’) : ‘{value of variable}’])

1 Like

Thank you for your reply. The section calling an existing testObject from the repository wasn’t quite what I was looking for as it threw a hashmap related error so I probably did that wrong on my initial attempt, but more specifically the Test Objects in Script view was able to do more of what I am looking for.

Thanks again for the support!