如何识别链接,我检查了如下元素:
<div class="vmKOT" role="navigation">
<a class="Ml68il" href="https://www.google.com" aria-label="Search" data-track-as="Welcome Header Search"></a>
<a class="WaidDw" href="https://mail.google.com" aria-label="Mail" data-track-as="Welcome Header Mail"></a>
<a class="a4KP9d" href="https://maps.google.com" aria-label="Maps" data-track-as="Welcome Header Maps"></a>
<a class="QJOPee" href="https://www.youtube.com" aria-label="YouTube" data-track-as="Welcome Header YouTube"></a>
</div>
我想识别类 WaidDw
或 href
并使用 python
单击
它。
最佳答案
你可以试试
driver.find_element_by_class_name('WaidDw').click()
或
driver.find_element_by_xpath('//a[@href="https://mail.google.com" and @aria-label="Mail"]').click()
关于python - 如何在 python 中使用 webdriver 识别 http 链接的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42292272/