特殊的元素定位: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