gpt4 book ai didi

python-3.x - 如何点击复选框?甚至 aria-hidden 也是= true?

转载 作者:行者123 更新时间:2023-12-02 23:44:42 25 4
gpt4 key购买 nike

它给了我元素不可见的错误。下面我提到了JavaScript代码。我想点击 aMRI。

我正在使用 python selenium:

driver.find_element_by_xpath("//label[@for = 'aMRI' and @class = 'checkbox-label']//span[@class='checkbox']//input[@id='aMRI']").click()

HTML:

<div class="col-md-8">
<label for="aMRI" class="checkbox-label">
<span class="checkbox">
<input type="checkbox" id="aMRI">
<i class="fa fa-check" aria-hidden="true"></i>
</span> MRI
</label>
<label for="aCase1" class="checkbox-label">
<span class="checkbox">
<input type="checkbox" id="aCase1">
<i class="fa fa-check" aria-hidden="true"></i>
</span> Case1
</label>
<label for="aDistibution" class="checkbox-label">
<span class="checkbox">
<input type="checkbox" id="aDistibution">
<i class="fa fa-check" aria-hidden="true"></i>
</span> Distibution
</label>
<label for="aBandwidth" class="checkbox-label hide">
<span class="checkbox">
<input type="checkbox" id="aBandwidth">
<i class="fa fa-check" aria-hidden="true"></i>
</span> Bandwidth
</label>
</div>

最佳答案

根据您共享的 HTML,单击与 <label> 相关的复选框文本为MRI,您可以使用以下代码行:

driver.find_element_by_xpath("//label[@for='aMRI']").click()

关于python-3.x - 如何点击复选框?甚至 aria-hidden 也是= true?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50355725/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com