2
votes

I am trying to select an item from a dropdown list in robot framework (using RIDE), but I cannot get the item by variable name.

<div class="chosen-drop">
    <div class="chosen-search">
        <input type="text" autocomplete="off">
    </div>
    <ul class="chosen-results">
        <li class="active-result" data-option-array-index="0">Geen optie gekozen</li>
        <li class="active-result" data-option-array-index="2">ABB</li>
        <li class="active-result" data-option-array-index="3">Algem</li>
        <li class="active-result" data-option-array-index="4">AOV</li>
        <li class="active-result" data-option-array-index="5">AW</li>
        <li class="active-result" data-option-array-index="8">AOZ</li>
    </ul>
</div>

I can use this and get the result:

Click Element    xpath=//*[@id="KEUZE_N_MiddelId_N1010D_chosen"]
Click Element    xpath=//*

[@id="KEUZE_N_MiddelId_N1010D_chosen"]/div/ul/li[4]

But the index number can change, so I want to click the element based on the value, in this example 'ABB'. How can I achieve this?

2
Have you tried Select from list? - Bryan Oakley
Try Select From List By Label - Sakshi Singla

2 Answers

1
votes

You can Try the following:

Select From List By Label| css=ul.chosen-results| ABB

0
votes

It is very similar to this SO post but not exact enough to be considered a duplicate. Based on your already achieved results I think this should work for you.

[@id="KEUZE_N_MiddelId_N1010D_chosen"]/div/ul/li[text() = 'ABB']