我想在这个html代码中单击下拉菜单按钮。
<div id="menu-button-:r1p:" aria-expanded="true" aria-haspopup="menu" aria-controls="menu-list-:r1p:" class="chakra-menu__menu-button css-6iqp1a" data-active="">
<span class="css-xl71ch">
<div class="css-70qvj9">Aa
</div>
</span>
</div>
<div class="css-r6z5ec" style="visibility: hidden; position: absolute; min-width: max-content; inset: 0px auto auto 0px;">
<div tabindex="-1" role="menu" id="menu-list-:rt:" aria-orientation="vertical" class="chakra-menu__menu-list css-17zw3g2" style="transform-origin: var(--popper-transform-origin); opacity: 0; visibility: hidden; transform: scale(0.8) translateZ(0px);">
<button type="button" aria-label="Font size 12px" id="menu-list-:rt:-menuitem-:ru:" role="menuitem" tabindex="-1" class="chakra-menu__menuitem css-13c7rae" data-index="0" aria-disabled="false">12</button>
<button type="button" aria-label="Font size 13px" id="menu-list-:rt:-menuitem-:rv:" role="menuitem" tabindex="-1" class="chakra-menu__menuitem css-13c7rae" data-index="1" aria-disabled="false">13</button>
<button type="button" aria-label="Font size 14px" id="menu-list-:rt:-menuitem-:r10:" role="menuitem" tabindex="-1" class="chakra-menu__menuitem css-13c7rae" data-index="2" aria-disabled="false">14</button>
<button type="button" aria-label="Font size 15px" id="menu-list-:rt:-menuitem-:r11:" role="menuitem" tabindex="-1" class="chakra-menu__menuitem css-13c7rae" data-index="3" aria-disabled="false">15</button>
<button type="button" aria-label="Font size 16px" id="menu-list-:rt:-menuitem-:r12:" role="menuitem" tabindex="-1" class="chakra-menu__menuitem css-13c7rae" data-index="4" aria-disabled="false">16</button>
<button type="button" aria-label="Font size 17px" id="menu-list-:rt:-menuitem-:r13:" role="menuitem" tabindex="-1" class="chakra-menu__menuitem css-13c7rae" data-index="5" aria-disabled="false">17</button>
<button type="button" aria-label="Font size 18px" id="menu-list-:rt:-menuitem-:r14:" role="menuitem" tabindex="-1" class="chakra-menu__menuitem css-13c7rae" data-index="6" aria-disabled="false">18</button>
<button type="button" aria-label="Font size 19px" id="menu-list-:rt:-menuitem-:r15:" role="menuitem" tabindex="-1" class="chakra-menu__menuitem css-13c7rae" data-index="7" aria-disabled="false">19</button>
<button type="button" aria-label="Font size 20px" id="menu-list-:rt:-menuitem-:r16:" role="menuitem" tabindex="-1" class="chakra-menu__menuitem css-13c7rae" data-index="8" aria-disabled="false">20</button>
</div>
</div>
我尝试:
find_element(通过. XPATH,"//* [@id ="菜单列表-:rt:-菜单项-:r15:"]")
另附:
find_element(按. ID,'菜单按钮-:rt:')
但它说:无此元素,无法定位元素。
我该怎么办?
1条答案
按热度按时间blmhpbnm1#
您可以尝试下面的点击菜单15,但要确保下拉菜单是打开的或值是可见的。
或