selenium svg标签定位元素


特殊的元素定位:svg,frame

SVG 指可伸缩矢量图形 (Scalable Vector Graphics)

需要xpath里面的name()方法:*[name()='svg']

 

从svg元素开始,下面的元素都要以  *[name()='svg'] 这种形式进行编写,需要通过 name 属性来进行定位。selenium在执行的时候才能够捕获到元素信息。

 

如果要同时需要该元素的其它属性可以用 and 的方式来进行定位。
写法如下:
//*[name()="svg" and @version="1.1"]//*[name()="image"]

 
get nodeLine() {
return '//div[@id="__map0-innerscroller"]/*[name()="svg"]/*[name()="g"]/*[name()="g"]/*[name()="g"][7]/*[name()="path"][2]';
}
 

verifyNodeLine() {
let selector = $(this.nodeLine);
if (selector.isDisplayed) {
selector.moveTo();
reportLog.attachScreenshot();
if ($(this.contextMenu.activePopover).isDisplayed()) {
return true;
}
}
return false;
}

 

进阶参考文档:

https://segmentfault.com/a/1190000009556665

https://www.cnblogs.com/tianma3798/p/6653936.html

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM