# How to use testobject within selenium code

**URL:** <https://forum.katalon.com/t/how-to-use-testobject-within-selenium-code/39115>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [January 27, 2020, 4:35pm UTC](https://forum.katalon.com/t/how-to-use-testobject-within-selenium-code/39115 "2020-01-27T16:35:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![vtanguturi](https://avatars.discourse-cdn.com/v4/letter/v/ce73a5/32.png) [@vtanguturi](https://forum.katalon.com/u/vtanguturi)\
**Post date:** [January 27, 2020, 4:35pm UTC](https://forum.katalon.com/t/how-to-use-testobject-within-selenium-code/39115/1 "2020-01-27T16:35:22Z")

</div>

Hi there,  
I am new to this tool and started using it recently. Please be patience if my question is already answered.  
I have defined the testobjects in the object repository. In my script I need to use them with selenium code  
Ex. I have WebUI.mouseOver(findTestObject(‘Page\_Home Agency Refresh/h2\_Featured Careers’))  
“selenium code”  
List FeaturedJobsList = driver.findElements(By.cssSelector(‘div.career-card’))

in the above code instead of I redefining the object by cssselector I want to refer to the test object that I have used in WebUI line something like  
List FeaturedJobsList = driver.findElements(‘Page\_Home Agency Refresh/h2\_Featured Careers’)

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [January 27, 2020, 9:39pm UTC](https://forum.katalon.com/t/how-to-use-testobject-within-selenium-code/39115/2 "2020-01-27T21:39:37Z")

</div>

You can find the source of `com.kms.katalon.core.testobject.TestObject` class.

> <https://github.com/katalon-studio/katalon-studio-testing-framework/blob/master/Include/scripts/groovy/com/kms/katalon/core/testobject/TestObject.java>

Please mind that the version of this source is not disclosed so that I am not sure if it is up to date or not.

By reading this, you would be able to find several ways how to inspect the internal of this class. In the end you may find a way to extract the CSS Selector out of the TestObject. Once found, you would want to pass it to the `driver.findElements(By.cssSelector(....))` part.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [January 28, 2020, 1:09am UTC](https://forum.katalon.com/t/how-to-use-testobject-within-selenium-code/39115/3 "2020-01-28T01:09:10Z")

</div>

@devalex88  
@ThanhTo

It is strange enough that the published Javadoc of Katalon

- [https://docs.katalon.com/javadoc/index.html](https://docs.katalon.com/javadoc/index.html)

does not include the `com.kms.katalon.core.testobject.TestObject` class.

Does Katalon Team want to intentionally hide it from public view?

---

<div class="post-metadata">

**Author:** ![r.klein1](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/r.klein1/32/23870_2.png) [@r.klein1](https://forum.katalon.com/u/r.klein1)\
**Post date:** [January 28, 2020, 7:07am UTC](https://forum.katalon.com/t/how-to-use-testobject-within-selenium-code/39115/4 "2020-01-28T07:07:06Z")

</div>

WebUiCommonHelper has functions to get a WebElement from TestObject and back

---

<div class="post-metadata">

**Author:** ![vtanguturi](https://avatars.discourse-cdn.com/v4/letter/v/ce73a5/32.png) [@vtanguturi](https://forum.katalon.com/u/vtanguturi)\
**Post date:** [January 28, 2020, 3:05pm UTC](https://forum.katalon.com/t/how-to-use-testobject-within-selenium-code/39115/5 "2020-01-28T15:05:39Z")

</div>

Thanks for your reply, I used as follow and its working for me

List numOfFeaturedJobs = WebUI.findWebElements(findTestObject(‘Page\_HomeCIA/Featuredjobslist’),10)

---

<div class="post-metadata">

**Author:** ![ThanhTo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/thanhto/32/697_2.png) [@ThanhTo](https://forum.katalon.com/u/ThanhTo)\
**Post date:** [January 28, 2020, 3:41pm UTC](https://forum.katalon.com/t/how-to-use-testobject-within-selenium-code/39115/6 "2020-01-28T15:41:46Z")

</div>

It’s probably due to the API were still in development when the docs are published. I will escalate to the team. Thanks !

---

<div class="post-metadata">

**Author:** ![discover.selenium](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/discover.selenium/32/522_2.png) [@discover.selenium](https://forum.katalon.com/u/discover.selenium)\
**Post date:** [January 29, 2020, 7:10am UTC](https://forum.katalon.com/t/how-to-use-testobject-within-selenium-code/39115/7 "2020-01-29T07:10:09Z")

</div>

@vtanguturi

```auto
WebUI.openBrowser('http://testSite/login.aspx')

WebUI.maximizeWindow()

WebDriver driver = DriverFactory.getWebDriver()

driver.findElement(By.xpath(findTestObject('SIT_Login_Page/UserName').findPropertyValue("xpath"))).sendKeys("User_Id") // WORKING

```
