How to manipulate a dropdown menu made of ul and li elements in Chromeless
Asked Answered
R

1

8

I am facing a drop down menu made of ul and li elements:

<ul class="o_dropdown_theme_values">
    <li class="" tabindex="-1">
        <label class="myclass" tabindex="0">Category 1</label>
    </li>
    <li class="" tabindex="-1">
        <label class="myclass" tabindex="0">Category 2</label>
    </li>
    ...
</ul>

I know two ways of modifying a dropdown menu with Chromeless:

.evaluate((dropDownValue) => {
    select = document.querySelector('select#category1')
    select.value = dropDownValue
}, dropDownValue)

and

.click('#id') 
.type("first letters of option", '#id') 
.click('#id option[value="'+dropDownValue+'"]') 

but because of the structure of the menu with ul and li, I am unable to use these.

I also tried to click on the menu and then press the tab key as many times as necessary to select the correct option, as if I was navigating the menu with my keyboard. But the Tab keys I am sending are not taken into account. I was able to send ONE (and only one) DOWN key (and not TAB) to the menu, but nothing more.

How can I manipulate this kind of menu? Any workaround based on javascript would be appreciated.

Radices answered 21/5, 2018 at 20:27 Comment(1)
I am not familiar with Chromeless but should you try to grab the text and not the value of the label?Chipmunk
R
5

I found a way in the end.

Use the .focus(#CSSselector) command to highlight the correct option and then valide with .press(13) (Enter key).

So that's a third way to manipulate dropdown menus in chromeless

Radices answered 2/6, 2018 at 9:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.