I want to select an item from list by value but show error “List with locator not found”
Element like below picture, I tried many xpath but still not found.
Could you help me or any suggestion.
#//[@id=“singe_select_payment_month_id_chosen”]/div/ul
#//[@id=“singe_select_payment_month_id_chosen”]/div
#//*[@id=“singe_select_payment_month_id_chosen”]
Hi Lieu,
Without more information on what your trying to do, all I can do is take a guess at your issue
Based on your dom, //[@id=“singe_select_payment_month_id_chosen”]/div/ul
should be //div[@id=“singe_select_payment_month_id_chosen”]/div/ul
, in xpath you need something before the square brace ([)
But I’m curious about your error being “List not found (dropdown list)”, are you trying to use a keyword like Select From List By Value or Get List Items? those list keywords are for <select> <option> lists (Form Elements), not Unordered or Ordered Lists
Hope that helps
Dave.
Hi Dave,
Yes I tried to use keyword “Select From List By Value”.
I also tried your suggestion, but it shown error like picture.
Hi Lieu,
Not sure why you’re getting that error, perhaps the double quote marks ("
) are not the standard ASCII double quote marks but rather the other slanted ones ones that sometimes happen.
Usually I construct and test the xpath in dev tools then just copy to my test case.
As i previously mentioned Select From List By Value
is not for selecting items from a <ul>
type list, so it’s still not clear what you are trying to acheive.
Dave.
Hi Dave,
I’ve been learning robot FW, so I tried to run keyword “Select From List By Value”.
And I just copy xpath on Chrome browser. I am still not understand xpath honestly.
The dropdown I want to test in below image. Could you suggest to me more option or information.
Thank you so much.
Hi Lieu,
As I mentioned before the keyword Select From List By Value
is not suitable for your HTML, it’s only for option lists.
I know what you show in your screenshot “looks” like an option list, but it’s not an option list, this is something that is becoming more common these days.
FYI the HTML for an option list would look like this:
<select>
<option value="0">All</option>
<option value="1">Oct-23</option>
<option value="2">Sep-23</option>
<option value="3">Aug-23</option>
<option value="4">Jul-23</option>
<option value="5">Jun-23</option>
<option value="6">May-23</option>
<option value="7">Apr-23</option>
<option value="8">Mar-23</option>
<option value="8">Feb-23</option>
</select>
What you also need to know this is nothing to do with robot framework either, if you used any other automation tool’s option list functions to interact with this page it would fail for the same reason.
What you probably need to do is use a Click, Wait for, Click combination, something like this:
Click Link //div[@id='singe_select_payment_month_id_chosen']/a
Wait Until Element Is Visible //div[@id=“singe_select_payment_month_id_chosen”]//ul/li[text()='May-23']
Click Element //div[@id=“singe_select_payment_month_id_chosen”]//ul/li[text()='May-23']
If you need to do this often then you could wrap this in a keyword and pass in variables for ID (singe_select_payment_month_id_chosen
) and Value (‘May-23’)
Hopefully that helps you understand why it doesn’t work as you expected.
Dave.