arc
arc

Reputation: 477

Click on a button outside a form (Ruby Mechanize)

I am trying to update this page by clicking a button that is outside of any forms using Ruby Mechanize. Does anyone know if this is possible? I know that I can't use the standard button submit. Below is a snippet of the html surrounding the button

<div class="details-section-contents">

  <div class="details-section-heading"></div>
  <div class="details-section-body expandable" data-load-more-section-id="reviews" data-load-more-docid="com.microsoft.office.officehub">
    <div></div>
    <button class="expand-button expand-next" style="display: block;">
        <div class="arrow-image-wrapper"></div>
        <div class="play-button"></div>
          ...

Upvotes: 1

Views: 793

Answers (1)

Severin
Severin

Reputation: 8588

Since you haven't provided too much information about the site I just give you the general approach.

Let's say you want to click a button. This probably triggers an http request like so: http://www.somesite.com/sub?params=1234. (I am sure you can figure out the action that the button performs.)

To get he response from it you can do:

Mechanize.new.get('http://www.somesite.com/sub?params=1234').parser

NOTE: Only append the .parser method call if you want the site to be parsed as Nokogiri Node Tree.

Upvotes: 1

Related Questions