Decalre Locator in Script

How can I declare my locator directly in the script without adding it to the object repository package? Below is what I followed and correct me if I am wrong.

WebUI.selectOptionByValue(findTestObject(“//*[@id=‘selectProject_0’]”), ‘32’, false)

2 solutions :
Use selenium, then no WebUI.someMethod :

Select dropdown = new Select(driver.findElement(By.id('selectProject_0')))
dropdown.selectByValue('32')

Code all your TestObjects :

TestObject to = new TestObject('test object name')
to.addProperty('xpath', ConditionType.EQUALS, "//*[@id='selectProject_0']") 
WebUI.selectOptionByValue(to, '32', false)

But your solution can’t work. findTestObject expect a path to a TestObject

I am getting multiple compilation Exception while running?? how to solve this???

Following is the code:

WebUI.callTestCase(findTestCase(‘LogIn_TestCase’), [:], FailureHandling.STOP_ON_FAILURE)

WebUI.click(findTestObject(‘UpdateTimesheet/Teamtimesheet’))

WebUI.delay(3)

WebUI.click(findTestObject(‘UpdateTimesheet/Timeperiodlink’))

WebUI.delay(3)

Select dropdown = new Select(driver.findElement(By.id('selectProject_0')))
dropdown.selectByValue('32')

WebUI.delay(5)

WebUI.click(findTestObject('Object Repository/UpdateTimesheet/plusicon'))

WebUI.delay(5)

Console Error:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Project/Scripts/UpdateTimesheet/Script1568956935370.groovy: 39: unable to resolve class Select
@ line 39, column 9.
Select dropdown = new Select(driver.findElement(By.id(‘selectProject_0’)))
^

Project/Scripts/UpdateTimesheet/Script1568956935370.groovy: 39: unable to resolve class Select
@ line 39, column 20.
Select dropdown = new Select(driver.findElement(By.id(‘selectProject_0’)))
^

2 errors

at com.kms.katalon.core.main.ScriptEngine.getScript(ScriptEngine.java:199)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1568974634644.run(TempTestCase1568974634644.groovy:21)

For 2nd method i am getting following error:

2019-09-20 15:52:09.316 ERROR c.k.katalon.core.main.TestCaseExecutor - :x: Test Cases/UpdateTimesheet FAILED.
Reason:
groovy.lang.MissingPropertyException: No such property: ConditionType for class: Script1568956935370
at UpdateTimesheet.run(UpdateTimesheet:40)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1568974864784.run(TempTestCase1568974864784.groovy:21)

For the two, press Ctrl + Shift + O to add imports