我正在尝试点击取消按钮,这是在打印文件中的chrome。下面是HTML
<cr-button class="cancel-button" aria-disabled="false" role="button" tabindex="0">
Cancel
</cr-button>我已经尝试了以下方法,但不起作用
driver.get(resume_url)
driver.maximize_window()
# Trial
driver.find_element_by_css_selector('cancel-button').click()
# Trial
driver.find_element_by_link_text('Cancel').click()所有这些操作都没有成功,并返回以下错误:
Message: no such element: Unable to locate element: {"method":"link text","selector":"Cancel"}
(Session info: chrome=89.0.4389.114)发布于 2021-04-12 09:27:03
通过链接文本定位元素仅适用于锚点元素。
https://selenium-python.readthedocs.io/locating-elements.html#locating-hyperlinks-by-link-text
要使用类名作为选择器,只需在开头附加一个句号。这行得通吗?
driver.find_element_by_css_selector('.cancel-button').click()https://stackoverflow.com/questions/67041456
复制相似问题