Selenium 在 XPath 中找不到 SVG 元素 [英] Selenium cannot find SVG element in XPath
本文介绍了Selenium 在 XPath 中找不到 SVG 元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下 HTML:
解决方案 试试下面的 XPath 表达式:
//*[local-name() = 'svg']
(至少可以在 Chrome/FireBug 控制台上工作,还没有尝试使用 Selenium)
I have the following HTML:
<div id="imageholder>
<svg>
<g> <image href='blah.gif'> </g>
</svg>
</div>
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']
None of them can locate my svg element. Sometimes I get the error:
error = TypeError: e.scrollIntoView is not a function
I'm using this as a means to use the locator in JUnit 4 testing if that helps.
解决方案 Try the following XPath expression:
//*[local-name() = 'svg']
(works at least from Chrome/FireBug console, haven't tried with Selenium yet)
这篇关于Selenium 在 XPath 中找不到 SVG 元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文