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