Selenium WebDriver: clicking on elements within an SVG using XPath

前端 未结 8 1253
难免孤独
难免孤独 2020-11-28 23:02

I have an SVG object with a few circle and rectangle elements. Using webdriver, I can click on the main svg object, but not any of the elements within it. The problem only s

8条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-28 23:29

    Here you go:

    driver.findElement(By.cssSelector("#canvas > svg > rect")).getAttribute("x") 
    driver.findElement(By.cssSelector("#canvas > svg > rect")).getAttribute("y") 
    

    This way you can do it.

提交回复
热议问题