views:

176

answers:

1

I have a button on my page that changes depending on what radio button is clicked. The button has the same text on it with the same id, but different classes. How do I test if the two different buttons exist depending on the radio.

<a id="submit" class="on" href="javascript:submit();">Submit</a>
<a id="submit" class="off" href="javascript:submit();">Submit</a>

How do i test if the second button appears instead of the first one. I used something like, browser.link(:text, 'Submit').exist?

but this doesn't work cause it will return true no matter what. thanks

edit: I'm looking around and found some stuff with xpath? i tried this out and it doesn't seem to work.

(browser.element_by_xpath("span[@id = 'submit'] span[@class
= 'on']/").exists?)

Something that might be important that i forgot to mention before is that the there is also a second set of buttons that use the class on and off but have a different id. So i need to specifically test for the class on, and the id submit. and then the class off and the id submit. Thanks

+2  A: 

It is a link, not a button. (It could look like a button, but it is still a link.)

This should work:

browser.link(:id => "submit", :class => "on").exist?
Željko Filipin