【发布时间】:2018-03-22 01:04:03
【问题描述】:
我想分别点击或更多,展开“任何时候”按钮。我试图通过 class_name 和 xpath 来定位元素。问题是类和 xpath 对于所有三个“选项”都是相同的。因此,我想使用 aria-label 选择并单击或展开该元素。我找到了一些建议,但对我没有用。最重要的是,我尝试在 python 3 中做到这一点。我也尝试过:
driver.find_element_by_xpath(""" //div*[@aria-label='Any Time'] """).click()
但它不起作用。
谁能帮帮我?非常感谢!
<div class="hdtb-mn-hd" aria-haspopup="true" role="button" tabindex="0" aria-label="Any country"><div class="mn-hd-txt">Any country</div><span class="mn-dwn-arw"></span></div>
<div class="hdtb-mn-hd" aria-haspopup="true" role="button" tabindex="0" aria-label="Any time"><div class="mn-hd-txt">Any time</div><span class="mn-dwn-arw"></span></div>
<div class="hdtb-mn-hd" aria-haspopup="true" role="button" tabindex="0" aria-label="All results"><div class="mn-hd-txt">All results</div><span class="mn-dwn-arw"></span></div>
【问题讨论】: