硒无法在XPath中找到SVG元素 [英] Selenium cannot find SVG element in XPath
本文介绍了硒无法在XPath中找到SVG元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下HTML:
<div id="imageholder>
<svg>
<g> <image href='blah.gif'> </g>
</svg>
</div>
我似乎根本无法在firefox上找到带有Selenium IDE的svg.我已经尝试过:
And I cannot seem to locate the svg with selenium IDE on firefox at all. I have tried:
//svg
//svg:svg
//*[name()='svg']
//*[namespace-uri()='http://www.w3.org/2000/svg']
他们都找不到我的svg元素.有时我会收到错误消息:
None of them can locate my svg element. Sometimes I get the error:
error = TypeError: e.scrollIntoView is not a function
如果有帮助,我正在以此为手段在JUnit 4测试中使用定位器.
I'm using this as a means to use the locator in JUnit 4 testing if that helps.
推荐答案
尝试以下XPath表达式:
Try the following XPath expression:
//*[local-name() = 'svg']
(至少可以在Chrome/FireBug控制台上运行,尚未尝试使用Selenium)
(works at least from Chrome/FireBug console, haven't tried with Selenium yet)
这篇关于硒无法在XPath中找到SVG元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文