Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Troubles with drop-down automation
#1
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">
    <li>
        <a href="#">text1</a>
    </li>
    <li>
        <a href="#">text2</a>
    </li>
    <li>
        <a href="#">text3</a>
    </li>
</ul>
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...
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020