Python Forum

Full Version: Troubles with drop-down automation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm having some troubles with clicking a item in a drop-down menu/list..

I'm using Selenium Web Driver, Chrome specifically, and i have the next "button" :

<button id="btn" class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-expanded="false">Nope</button>
<ul id="ulDropdownNivel2" class="dropdown-menu">
        <a href="#">text1</a>
        <a href="#">text2</a>
        <a href="#">text3</a>
So.. i have tried to use Select.class of Selenium Wd but, it's a button, and the class can't be used there... tried using it on the <ul> but it can't use Select neither...

Can't use smh like:
dropdoun = Select(driver.find_element_by_id('ID'))
for elm in dropdoun{ print(elm.text())}
Tried to figure a way to iterate through items... but i didn't get anything

I figured a way to click by xPath but, it doesn't work to me, cause text1, text2, text3 and so changes the order everytime you open the web

What i need to do here, is to iterate trough each item, and select the one that match with "text1", "text2" or "text3...