带有类名的下拉列表不适用于选择功能Selenium

时间:2018-08-06 13:15:54

标签: selenium select xpath drop-down-menu

我有一条路:

<div class="jss601 jss602 jss581" aria-pressed="false" tabindex="0" role="button" aria-haspopup="true" xpath="1"><span></span></div>

但是我无法编写用于单击元素的XPath或CSS。你能帮我吗?

这是一个称为“提示”的下拉列表,我如何管理选择,因为它不是选择,所以我不能使用选择功能:

HTML:

<ul class="MuiList-root-139 MuiList-padding-140" role="listbox" xpath="1">
    <li tabindex="-1" class="MuiButtonBase-root-55 MuiListItem-root-143 MuiListItem-default-146 MuiListItem-gutters-150 MuiListItem-button-151 MuiMenuItem-root-296" role="option" data-value="">Hiçbiri
        <span class="MuiTouchRipple-root-64"></span>
    </li>
    <li tabindex="-1" class="MuiButtonBase-root-55 MuiListItem-root-143 MuiListItem-default-146 MuiListItem-gutters-150 MuiListItem-button-151 MuiMenuItem-root-296" role="option" data-value="RTU">RTU
        <span class="MuiTouchRipple-root-64"></span>
    </li>
    <li tabindex="0" class="MuiButtonBase-root-55 MuiListItem-root-143 MuiListItem-default-146 MuiListItem-gutters-150 MuiListItem-button-151 MuiMenuItem-root-296 MuiMenuItem-selected-297" role="option" data-value="Substation Control System">Substation Control System
        <span class="MuiTouchRipple-root-64"></span>
    </li>
    <li tabindex="-1" class="MuiButtonBase-root-55 MuiListItem-root-143 MuiListItem-default-146 MuiListItem-gutters-150 MuiListItem-button-151 MuiMenuItem-root-296" role="option" data-value="Control Center">Control Center
        <span class="MuiTouchRipple-root-64"></span>
    </li>
    <li tabindex="-1" class="MuiButtonBase-root-55 MuiListItem-root-143 MuiListItem-default-146 MuiListItem-gutters-150 MuiListItem-button-151 MuiMenuItem-root-296" role="option" data-value="IED">IED
        <span class="MuiTouchRipple-root-64"></span>
    </li>
</ul>

<li tabindex="-1" class="MuiButtonBase-root-55 MuiListItem-root-143 MuiListItem-default-146 MuiListItem-gutters-150 MuiListItem-button-151 MuiMenuItem-root-296" role="option" data-value="RTU" xpath="1">RTU
    <span class="MuiTouchRipple-root-64"></span>
</li>

1 个答案:

答案 0 :(得分:0)

在这里您可以找到一个下拉示例,以及如何在此下拉菜单中找到元素。

Selenium - Python - drop-down menu option value