selenium 在 IE 中找不到带有 class 的元素
我将 selenium_client 与黄瓜、webrat + IE 一起使用 正如您所期望的,Firefox 运行良好。我已尝试以下操作:
selenium.is_visible("css=#flash .flash_notice")
selenium.is_visible("xpath=//*[@id='flash']/*[@class='flash_notice]")
selenium.is_visible("xpath=//*[@id='flash']/*[contains(@class,'flash_notice]')")
两者都找不到该元素。 我认为这一定与 IE 有关,仔细观察 IE 的 html selenium 返回... 它看起来像这样:
<UL id=flash>
<LI className=flash_notice>Deleted</LI>
</UL>
注意 IE 将类属性返回为 className,这是令人困惑的 selenium 吗?我怎样才能解决这个问题,以便我可以使用 IE 和 Firefox 对 selenium 使用相同的语句
只是为了让我们更加困惑,这个例子有效,确认它与检查类属性有关
selenium.is_visible("xpath=//*[@id='flash']/*[. =\'Deleted\']")
I'm using selenium_client with cucumber, webrat + IE
As you'd expect, Firefox works fine. I've tried the following:
selenium.is_visible("css=#flash .flash_notice")
selenium.is_visible("xpath=//*[@id='flash']/*[@class='flash_notice]")
selenium.is_visible("xpath=//*[@id='flash']/*[contains(@class,'flash_notice]')")
both cannot find the element.
I think it must be something to do with IE, looking closer at the html selenium returns from IE...
It looks like this:
<UL id=flash>
<LI className=flash_notice>Deleted</LI>
</UL>
Notice IE returns the class attribute as className, is this confusing selenium? How can I get round this so that I can use the same statement for selenium using IE and Firefox
Just to confuse us even more, this example works, confirming its something to do with checking the class attribute
selenium.is_visible("xpath=//*[@id='flash']/*[. =\'Deleted\']")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的 XPATH 表达式似乎格式不正确。
第一个 XPATH 缺少
flash_notice
末尾的单引号'
。应该是:
selenium.is_visible("xpath=//*[@id='flash']/*[@class='flash_notice']")
第二个XPATH 的
'
]
和)
顺序不正确,这会弄乱表达式。应该是:
selenium.is_visible("xpath=//*[@id='flash']/*[contains(@class,'flash_notice')]")
It appears that your XPATH expressions are mal-formed.
The first XPATH is missing the single quote
'
at the end offlash_notice
.It should be:
selenium.is_visible("xpath=//*[@id='flash']/*[@class='flash_notice']")
The second XPATH has the
'
]
and)
out of order, which messes up the expression.It should be:
selenium.is_visible("xpath=//*[@id='flash']/*[contains(@class,'flash_notice')]")