5
votes

I have been struggling with this all morning and was hoping to get some assistance. I have this button on a webpage that pulls up a control panel that lets the user select which widgets to display. I'm trying to get this to fire using watir webdriver and firefox 9.0 but having no luck at all. I'm able to login to the site, get to the page that contains the button but just can't click the 'CHOOSE YOUR FEATURES' button.

<div class="personalizationButton">
  <span class="personalizationStatus"></span>
  &nbsp;
  <b class="widgetPanelLink neo-button button-white">
    <span>CHOOSE YOUR FEATURES</span>
  </b>
</div>`

I've been concentrating on using div class 'personalizationButton' but perhaps I need to point to that 'b class'? Just not sure how to format it. Here are some examples of what I have tried

$browser.div(:class, 'personalizationButton').when_present.click 
$browser.button(:text => 'CHOOSE YOUR FEATURES').click 
$browser.button(:div => 'personalizationButton').click 

etc, etc... just not sure I'm getting the format right. I watch it get to the page, I see the 'CHOOSE YOUR FEATURES' button on the page, but it never clicks it. Usually I get an error like this depending on which version was used:

unable to locate element, using {:text=>"CHOOSE YOUR FEATURES", :tag_name=>"button"}

This is the version I think should work, When I try it I get no errors but see nothing happen in the browser either:

$browser.div(:class => "personalizationButton").click
2
Derek, can you please post what you've tried so far with Watir? Thanks for providing the HTML up front (do you have a link?). Also, can you please post the error - is it not locating the div, or not clicking what you want, etc? - adam reed
$browser.div(:class, 'personalizationButton').when_present.click $browser.button(:text => 'CHOOSE YOUR FEATURES').click $browser.button(:div => 'personalizationButton').click etc, etc... just not sure I'm getting the format right. I watch it get to the page, I see the 'CHOOSE YOUR FEATURES' button on the page, but it never clicks it. Usually I get an error like this depending on which version was used: unable to locate element, using {:text=>"CHOOSE YOUR FEATURES", :tag_name=>"button"} - Derek
This is the version I think should work, but I get no errors and see nothing happen in the browser either: $browser.div(:class => "personalizationButton").click - Derek
This is all I see in IRB when I try it: >> $browser.div(:class => "personalizationButton").click => [] - Derek
what you likely have there is a div or span that is made to look like a button, likely via a backround image controlled via CSS and the style of the div/span. In this situation unless you can have a developer tell you what element is reacting to a click, you just have to try clicking on what is there. a B tag by the way is just boldface, it's a text formatting tag, and not generally clickable. - Chuck van der Linden

2 Answers

6
votes

I'm not seeing anything inherently clickable (with output) in the HTML. With the IRB output, it shows that it is finding the div, but there is no action when clicking it. The <b> element is just the "bold" style, so we shouldn't need to try that.

If you can access the span with text CHOOSE YOUR FEATURES, that should be your button.

$browser.span(:text => "CHOOSE YOUR FEATURES").click
0
votes

. . i have tried doing the same thing with godaddy.com buy it did work. on the main page there is a button labeled "Buy Now" using the code below brow.div(:class => 'gdhp-domain-link gdhp-rounded-corners').span(:text => 'Buy Now').click I was