Selenium 在 IE8 和 Firefox3.6 上使用 Xpath
是否有任何明显的原因可以解释为什么 Selenium 在 Firefox 浏览器上找到并成功执行以下命令,但不是 IE8(通过 selenium RC)
selenium.click("//input[@type='Radio'
and starts-with(@name, 'client-select')
and @value='0']");
我假设它与 IE“渲染”(不确定正确的术语)有关 xpath 与火狐浏览器。是这样吗?它们有何不同?您知道哪些文章可以帮助我克服有关两个浏览器和 xpath 的这个问题和类似问题?
非常感谢。
编辑
有问题的元素是:
<input type="Radio"
value="1"
onfocus=""
onclick="return doRTgl(this);"
onblur=""
name="client-select_1580158">
它嵌套在一些非常混乱的嵌套表中,并通过 Ajax 动态添加。
Is there any discernible reason as to why Selenium finds and successfully executes the following command on a Firefox browser, but not IE8 (via selenium RC)
selenium.click("//input[@type='Radio'
and starts-with(@name, 'client-select')
and @value='0']");
Im assuming its something to do with IE "rendering" (not sure the correct term) xpath differently to firefox. Is this the case? How do they differ? What articles do you know that will help me overcome this and similar issues regarding the two browsers and xpath?
Much thanks.
EDIT
The element in question is:
<input type="Radio"
value="1"
onfocus=""
onclick="return doRTgl(this);"
onblur=""
name="client-select_1580158">
Its nested within some pretty messed up nested tables, and is added dynamically via Ajax.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的解决方案是从 xpath 定位器中删除该类型,
幸运的是,这为我每次提供了足够的信息来查找唯一元素。
就一般问题而言,适用于 Firefox 的 xpath 不一定适用于 IE。这是我在重构代码期间发现的唯一情况。为了将来的参考,只需对每个进行测试,找出差异并解决问题。
My solution was to remove the type from the xpath locator
Which fortunately left me with enough information to find the unique element each time.
As far as the generic question, an xpath that works on Firefox won't necessarily work on IE. This was the only case however I found during refactoring of my code. For future reference, just have to test on each, find the differences and work around.