HI there,
could some one help me on this case
i have an dropdown list as below: Imgur: The magic of the Internet
i want to select by timeslot by xpath, value of timeslot comes from variable:
//*[@id=“availableTimeSlot”]//ul/li[@value=“%s”]
to use Test Object from katalon
I need to cast xpath string of timeslot to Test Object via this code:
public class Timeslot { public static def TestObject returnXpathOfSelectedTimeslot(String selectorType, String selectorValue) { TestObject to = new TestObject() to.addProperty(selectorType, ConditionType.EQUALS, selectorValue) return to } public static def String getTimeslotXpathByValue(int timeslot) { TestObject timeslotObject = findTestObject('Object Repository/reservationHomePage/Timeslots/timeslotByValue') String timeslotString = timeslotObject.findPropertyValue("xpath") return String.format(timeslotString, timeslot) } }
note: after casting, the properly xpath is returned, wait for element present ok but can’t click to it,
ON TESTCASE
int timeslot = 1900
WebUI.click(findTestObject(‘Object Repository/reservationHomePage/Timeslots/pleaseSelect’))
WebUI.delay(1)
WebUI.waitForElementPresent(Timeslot.returnXpathOfSelectedTimeslot(“xpath”, Timeslot.getTimeslotXpathByValue(timeslot)), 3)
WebUI.click(Timeslot.returnXpathOfSelectedTimeslot(“xpath”, Timeslot.getTimeslotXpathByValue(timeslot)), FailureHandling.STOP_ON_FAILURE)
WebUI.closeBrowser()
ERROR detail:
test Cases/SelectTimeslots/tc1 FAILED. Reason: com.kms.katalon.core.exception.StepFailedException: Unable to click on object '' at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64) at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26) at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.click(ClickKeyword.groovy:86) at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.execute(ClickKeyword.groovy:67) at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56) at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:604) at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$4.call(Unknown Source) at tc1.run(tc1:27) 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:331) at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:322) at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:301) at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:293) at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:227) 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 TempTestCase1555657238908.run(TempTestCase1555657238908.groovy:21) Caused by: org.openqa.selenium.ElementNotVisibleException: element not interactable (Session info: chrome=73.0.3683.103) (Driver info: chromedriver=2.43.600210
just big note: when i use this: driver.findElement(By.xpath(‘//*[@id=“availableTimeSlot”]//ul/li[@value=“1900”]’)).click()
It can work ok
thank in advance!