Selenium cannot find SVG element in XPath

前端 未结 2 1878
臣服心动
臣服心动 2020-12-14 07:03

I have the following HTML:

相关标签:
2条回答
  • 2020-12-14 07:06

    Try the following XPath expression:

    //*[local-name() = 'svg']
    

    (works at least from Chrome/FireBug console, haven't tried with Selenium yet)

    0 讨论(0)
  • 2020-12-14 07:21

    The question is about xPath, but if you can use CSS Selectors, that would be more readable, like so (Java).

    WebElement image = driver.findElement(By.cssSelector("#imageholder > svg > g > image"));
    
    0 讨论(0)
提交回复
热议问题