【问题标题】:Python Selenium, obtaining XPath given hrefPython Selenium,获取 XPath 给定的 href
【发布时间】:2018-04-24 21:44:08
【问题描述】:

一旦我通过在 Python 中使用 Selenium 获得了href

有没有办法根据href 找到XPath 并点击XPath

例如:

href = '/sweatshirts/vct65b9ze/yn2gxohw4' 

如何在该页面上找到XPath

【问题讨论】:

标签: python selenium xpath selenium-webdriver href


【解决方案1】:

当元素例如是一个链接时,您可以使用以下代码:

     driver.find_element_by_xpath('//a[@href="/sweatshirts/vct65b9ze/yn2gxohw4"]');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-09
    • 2021-07-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-08
    相关资源
    最近更新 更多