【发布时间】:2020-06-17 00:18:14
【问题描述】:
我正在尝试使用 selenium 代码打开/关闭切换开关。问题是我想通过它的“文本标签”而不是它的 ID 或名称来访问切换开关。这是开关的 HTML
<input type="checkbox" name="ot-group-id-C0002" class="switch-checkbox category-switch-handler" id="ot-group-id-C0002" aria-checked="true" aria-controls="ot-desc-id-C0002" aria-labelledby="ot-header-id-C0002" data-optanongroupid="C0002" checked="true" tabindex="0">
<label class="switch-label" for="ot-group-id-C0002">
<span class="switch-inner"></span>
<span class="switch-nob"></span>
<span class="label-text">Performance Cookies</span>
</label>
我想通过文本“Performance Cookies”而不是其 ID 或名称来访问切换开关。
【问题讨论】:
-
请您的代码试用
标签: python selenium selenium-webdriver