首页 > 解决方案 > 如何使用 selenium webdriver python 单击跨度文本

问题描述

无法通过跨标签内的 selenium Web 驱动程序单击“继续”按钮。

<span style="align-items: center; align-self: center; flex: 1 1 auto; margin: 0px 4px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
    <span>Continue</span>
</span>

标签: pythonseleniumselenium-webdriverxpathwebdriver

解决方案


从技术上讲,您不单击跨度文本,而是单击<span>带有文本的继续,您可以使用以下解决方案:

driver.find_element_by_xpath("//span/span[contains(.,'Continue')]").click()

推荐阅读