【Selenium】通过xpath定位svg元素

SVG 意为可缩放矢量图形(Scalable Vector Graphics)
定位svg元素要用xpath的name()函数,比如//svg/line[2],要用//*[name()='svg']/*[name()='line'][2]"代替

刚验证了一下,这样写是可以的
//div[@class='tg-tree-item'][text()='sharing']//ancestor::div[contains(@class,'tg-row')]/div[contains(@class,'action-menu-icon')]/div/div/*[name()='svg']

原文地址:https://www.cnblogs.com/MasterMonkInTemple/p/10528623.html