【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']

posted on 2019-03-14 10:31  张缤分  阅读(1359)  评论(0编辑  收藏  举报

导航