开发者

selenium cannot find element with class in IE

开发者 https://www.devze.com 2022-12-26 19:02 出处:网络
I\'m using selenium_client with cucumber, webrat + IE As you\'d expect, Firefox works fine. I\'ve tried the following:

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 ch开发者_开发百科ecking the class attribute

selenium.is_visible("xpath=//*[@id='flash']/*[. =\'Deleted\']")


It appears that your XPATH expressions are mal-formed.

The first XPATH is missing the single quote ' at the end of flash_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')]")

0

精彩评论

暂无评论...
验证码 换一张
取 消