Clicking on svg using selenium python

后端 未结 2 1828
执念已碎
执念已碎 2020-11-30 13:20

svg icon is clickable.

相关标签:
2条回答
  • 2020-11-30 13:56

    The "svg" elements are not from the XHTML namespace but belongs to SVG namespace. Hence you have to specify name()="svg" while constructing the xpath for svg tags. for example : "/*[name()='svg']/*[name()='path'] "

    For your reference , please find below discussion How to click on SVG elements using XPath and Selenium WebDriver through Java

    0 讨论(0)
  • 2020-11-30 14:14

    To click() on the svg icon you can use the following solution:

    driver.find_element_by_xpath('//div[@class="some-class"]/*[name()="svg"][@aria-label="Search"]').click()
    

    You can find a couple of relevant discussions in:

    • How to click on SVG elements using XPath and Selenium WebDriver through Java
    • Unable to locate SVG elements through xpath on Kendo UI chart
    0 讨论(0)
提交回复
热议问题