Search code examples
pythonseleniumselenium-webdriverrobotframeworkant-design-pro

How to select a list item from the dropdown list using Xpath for Robot framework Selenium Python


I want to select Textes3 with robot framework from the dropdown.

HTML:

<div class="ant-select-dropdown ant-select-dropdown--single ant-select-dropdown-placement-bottomLeft" style="width: 389px; left: 342px; top: 969px; display: none;">
<div id="eryerye12ry56756rt" tabindex="-1" class="ant-select-dropdown-content" style="overflow: auto; transform: translateZ(0px);">
<ul role="listbox" tabindex="0" class="ant-select-dropdown-menu ant-select-dropdown-menu-vertical ant-select-dropdown-menu-root">
<li role="option" class="ant-select-dropdown-menu-item ant-select-dropdown-menu-item-active" unselectable="on" brnalid="ethduyuyuyujfyeroT" style="user-select: none;"> Texte1 </li>
<li role="option" class="ant-select-dropdown-menu-item" unselectable="on" brnalid="ksdhfiyzegyufizyefge" style="user-select: none;"> Texte2 </li>
<li role="option" class="ant-select-dropdown-menu-item" unselectable="on" brnalid="zrzeonvisyjrddudgfi56" style="user-select: none;"> Texte3 </li>
</ul>
</div>
</div>

Solution

  • if you want to select the text "Textes3" from the above you can use the below xpath

    //li[contains(text(),'Textes3')].click();
    

    If this does not answer your question, so please explain it more.