How to get TestObject property

Hello!

I want to get TestObject ‘tag’ property to check if it is ‘input’ or ‘select’.

It exists a function to do that please? Something like getProperty(‘tag’)?

I don’t know if using findPropertyValue(String) is the good way…

Thank’s a lot.

hello,
there is xpath fuction that can be used > local-name()

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObjectimport com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUIWebUI.openBrowser('http://forum.katalon.com/discussion/8461/how-to-get-testobject-property#latest')WebUI.waitForElementVisible(findTestObject('Object Repository/__Sandbox/to'),5)println CustomKeywords.'com.swre.tools.exexpath'('local-name(//a[contains(@class, "FullName")])', 'STRING_TYPE') 

console:07-20-2018 11:54:56 AM - [INFO]   - Finding web element with id: 'Object Repository/__Sandbox/to' located by 'By.xpath: //a[contains(@class, 'FullName')]' in '5' second(s)07-20-2018 11:54:56 AM - [INFO]   - Found 1 web elements with id: 'Object Repository/__Sandbox/to' located by 'By.xpath: //a[contains(@class, 'FullName')]' in '5' second(s)07-20-2018 11:54:56 AM - [PASSED] - Object 'Object Repository/__Sandbox/to' is visible07-20-2018 11:54:56 AM - [END]    - End action : waitForElementVisible07-20-2018 11:54:56 AM - [START]  - Start action : Statement - println(CustomKeywords.com.swre.tools.exexpath("local-name(//a[contains(@class, "FullName")])", "STRING_TYPE"))07-20-2018 11:54:57 AM - [PASSED] - com.swre.tools.exexpath is PASSEDa07-20-2018 11:54:57 AM - [END]    - End action : Statement - println(CustomKeywords.com.swre.tools.exexpath("local-name(//a[contains(@class, "FullName")])", "STRING_TYPE"))07-20-2018 11:54:57 AM - [PASSED] - Test Cases/__Sandbox/New Test Case 207-20-2018 11:54:57 AM - [END]    - End Test Case : Test Cases/__Sandbox/New Test Case 2

custom keyword for running such function is here:

1 Like

I will try this solution, thanks.

However, I found this function :

String tagName = object.findPropertyValue('tag')

Nicolas Lamblin said:

I will try this solution, thanks.

However, I found this function :

String tagName = object.findPropertyValue('tag')

IMHO, upper code will return what is set in object as property and will not return tag type

def of to object

println CustomKeywords.'com.swre.tools.exexpath'('local-name(//a[contains(@class, "FullName")])', 'STRING_TYPE')println findTestObject('Object Repository/__Sandbox/to').findPropertyValue('tag')

console log07-20-2018 03:33:03 PM - [START]  - Start action : Statement - println(CustomKeywords.com.swre.tools.exexpath("local-name(//a[contains(@class, "FullName")])", "STRING_TYPE"))07-20-2018 03:33:03 PM - [PASSED] - com.swre.tools.exexpath is PASSEDa07-20-2018 03:33:03 PM - [END]    - End action : Statement - println(CustomKeywords.com.swre.tools.exexpath("local-name(//a[contains(@class, "FullName")])", "STRING_TYPE"))07-20-2018 03:33:03 PM - [START]  - Start action : Statement - println(com.kms.katalon.core.testobject.ObjectRepository.findTestObject(Object Repository/__Sandbox/to).findPropertyValue("tag"))07-20-2018 03:33:03 PM - [INFO]   - Finding Test Object with id 'Object Repository/__Sandbox/to'07-20-2018 03:33:03 PM - [END]    - End action : Statement - println(com.kms.katalon.core.testobject.ObjectRepository.findTestObject(Object Repository/__Sandbox/to).findPropertyValue("tag"))07-20-2018 03:33:03 PM - [PASSED] - Test Cases/New Test Case07-20-2018 03:33:03 PM - [END]    - End Test Case : Test Cases/New Test Case

image.png

1 Like

.

My objective was to find the property of an existing object.
But I think that your solution is more safe.
Thanks.