Drop down isnt picking up li Data Val

Hi, I think i have confused myself and got myself in a bit of a tiss as I have read so much trying to fix this issue.

I have a drop down that I want to be able to select different airports as and when required. However its in a filter and I cant get Katalon to select an airport. I just need a bit of guidance if anyone could help me please. This is the section I am trying to click

and when I spy web i get this://select[@id=‘filterdepartingFrom’]
and when I locate I get this: //div[@id=‘editFiltersContainer’]/div/div[2]/div[2]/div/div/ul/li[2]/label
I have tried label/options/value and it just doesnt click it. This is the error I get when I try the select by label.

=============== ROOT CAUSE =====================
Caused by: com.kms.katalon.core.exception.StepFailedException: Unable to select option by label ‘Cardiff Airport’ of object ‘Object Repository/A search drop down/Page_Checkout/label_Any London Airport’

For trouble shooting, please visit: https://docs.katalon.com/katalon-studio/docs/troubleshooting.html

07-28-2022 08:51:53 PM Test Cases/Bookings for Titan/Titan Tour full booking

Elapsed time: 58.035s

Test Cases/Bookings for Titan/Titan Tour full booking FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Call Test Case ‘Test Cases/Checkout drop downs/Flight, date drop down’ failed
at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword$_callTestCase_closure1.doCall(CallTestCaseKeyword.groovy:63)
at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword$_callTestCase_closure1.call(CallTestCaseKeyword.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:74)
at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword.callTestCase(CallTestCaseKeyword.groovy:81)
at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword.execute(CallTestCaseKeyword.groovy:44)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:74)
at com.kms.katalon.core.keyword.BuiltinKeywords.callTestCase(BuiltinKeywords.groovy:334)
at Titan Tour full booking.run(Titan Tour full booking:24)
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:445)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:436)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:415)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:407)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:284)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1659037907375.run(TempTestCase1659037907375.groovy:25)
Caused by: com.kms.katalon.core.exception.StepFailedException: Unable to select option by label ‘Cardiff Airport’ of object ‘Object Repository/A search drop down/Page_Checkout/label_Any London Airport’
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.SelectOptionByLabelKeyword.selectOptionByLabel(SelectOptionByLabelKeyword.groovy:98)
at com.kms.katalon.core.webui.keyword.builtin.SelectOptionByLabelKeyword.execute(SelectOptionByLabelKeyword.groovy:71)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:74)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.selectOptionByLabel(WebUiBuiltInKeywords.groovy:1230)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$selectOptionByLabel$5.call(Unknown Source)
at Flight, date drop down.run(Flight, date drop down:36)
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:445)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:436)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:415)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:407)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:284)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
at com.kms.katalon.core.keyword.builtin.CallTestCaseKeyword$_callTestCase_closure1.doCall(CallTestCaseKeyword.groovy:59)
… 18 more
Caused by: org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been “select” but was “label”
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘F34VCL3’, ip: ‘192.168.68.103’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_282’
Driver info: driver.version: unknown
at org.openqa.selenium.support.ui.Select.(Select.java:48)
at com.kms.katalon.core.webui.keyword.builtin.SelectOptionByLabelKeyword$_selectOptionByLabel_closure1.doCall(SelectOptionByLabelKeyword.groovy:87)
at com.kms.katalon.core.webui.keyword.builtin.SelectOptionByLabelKeyword$_selectOptionByLabel_closure1.call(SelectOptionByLabelKeyword.groovy)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
… 33 more
Please someone take pity on me and help me. Ill treat you to cake :slight_smile:

2 Likes

Ah, CWL, Cardiff Airport… I know it well.

All the Select APIs expect an HTML <select> element which would itself contain a bunch of HTML <option> elements. But, like your topic subject line, what you’re trying to… uh… “select” :grinning: is an HTML <li> element. Therefore, try using WebUI.click() on the target <li> element.

If it turns out the XPath is giving you trouble targeting the correct <li>, post the error here. I’m concerned your XPaths look a little lengthy (i.e. brittle).

Meanwhile/also, search the forum for UL/LI dropdowns – you’re not the first (and certainly not the last) person to stumble on this problem.

p.s. Fantastic problem/question post. You managed to post EVERYTHING we need to help you. :heart:

3 Likes

Thank you so much for your help with this. Im going to take a look on the forum and I am sure in the words of Arnie, Ill be back :laughing:

so Russ, it looks like I over thought this through. It literally was a case of clicking it :rofl:. Now, I just need to figure out how to write something so it allows me to select the airport that I want.

But thank you so much for your help as I was literally going round in circles and it was literally a click.

2 Likes

Excellent.

Sadly, I’m not an XPath guru (I use CSS) but it seems your XPath can be changed to use the data-val attribute instead of id. So, using your xpath as a starting point…

//select[@id=‘filterdepartingFrom’]

let’s try this:

//li[@data-val='CWL']

image

2 Likes

OMG Russ, you are a genius (want to come and work with me as I could do with a tutor like you :heart_eyes:). It worked, I can pick up any of the airports. If I could send you a case of beer, I would. You dont know how much you have saved me and Enlighted me on something as well. :smiling_face_with_three_hearts:

3 Likes