Variable object name

Hello. I am converting an automation script I use which was built off selenium and java. I’ve run into an issue. I had to work through this when I first scripted this and now here I am again. The problem is the target website has a popup. There’s plenty of documentation about how to handle that, so no problem there.

The problem comes from the button to open the popup. Their site randomizes the id for the object.

From chrome - input type=“file” class=“upfile upfile_ultimo” name=“upfile_1507665492712” id=“upfile_1507665492712” size=“35” value=“”
From firefox - input class=“upfile upfile_ultimo” name=“upfile_1507665543947” id=“upfile_1507665543947” size=“35” value=“” type=“file”

Each run I make, the “name” and the “id” change. That presents a challenge for automation software to find the button I’m looking for. I have tried

WebUI.click(findTestObject(“input[class*=‘upfile_ultimo’]”))

but this didn’t work. I also tried it with “upfile upfile_ultimo”. The script I have that works is

driver.findElement(By.cssSelector(“input[class*=‘upfile_ultimo’]”)).click();

Is there a similar option I can use in Katalon?

WebUI.click(findTestObject("input[class*='upfile_ultimo']"))

This is not correct. findTestObject method takes TestObject parameter, not a string. If a class is still the same, do following:

String path = ".//input[@class='upfile upfile_ultimo']"
TestObject to = new TestObject().addProperty("xpath", ConditionType.EQUALS, path)
WebUI.click(to)

Thank you, Marek. However, that did not work. Just to be sure, this is what I have in my Katalon code right now …

‘Open browser and navigate to JPL site’
WebUI.openBrowser(‘http://apps.gdgps.net/apps_file_upload.php’)

‘Click on choose file button in iframe’
//WebUI.click(findTestObject(“input[class*=‘upfile_ultimo’]”))
String path = “.//input[@class=‘upfile upfile_ultimo’]”
TestObject to = new TestObject().addProperty(“xpath”, ConditionType.EQUALS, path)
WebUI.click(to)

It has yet to open the popup. With your addition, I’m getting the error, “Test Cases/JPL_upload FAILED because (of) Variable ‘ConditionType’ is not defined for test case.”

I’m not sure what ConditionType is looking for.

You’d have to import this class in order to use it.

import com.kms.katalon.core.testobject.ConditionType

Marek, you’re a god. Thank you so much!