Reputation: 2441
Trying to test a poll vote with Watir. Just using a script at the moment, and I can't get the script to find the correct button.
HTML (reformatted slightly for readability)
<a href="#" class="btn-poll-short"
data-action-url="http://url.com/poll/vote.do"
data-svar="svar1"
data-type="picture_5569154"
data-action="a:1" data-socialpollanswer="Yes"
data-pollid="5569154"
data-shareanswerpicture=""
onclick="s_objectID="http://www.url.com/news/world-news/protective-dad-makes-daughter-wear-5568808#_3";return this.s_oc?this.s_oc(e):true">
Yes
</a>
My method for the click action:
def vote
browser = Watir::Browser.new
browser.goto 'http://www.url.com/news/world-news/protective-dad-makes-daughter-wear-5568808'
sleep 5
browser.td(:class => 'btn-poll-short').span(:id => 'Yes').click
end
Upvotes: 1
Views: 818
Reputation: 5283
Based on your HTML, you should try:
browser.link(:class => 'btn-poll-short').click
or
browser.link(:text => 'Yes').click
In your vote
method, you are trying to locate a span within a table cell (instead of a link with a class attribute).
Upvotes: 1