0

I am trying to click on youtube's Load more button in the user's playlist section using Mechanize gem . But the problem is , i din't find any ways of clicking on a button using mechanize gem in my Rails application.

The html code of button which i want to click on is this :

<button class="yt-uix-button yt-uix-button-size-default yt-uix-button-default load-more-button yt-uix-load-more browse-items-load-more-button" data-uix-load-more-target-id="channels-browse-content-grid" data-uix-load-more-href="/browse_ajax?action_continuation=1&continuation=4qmFsgLLARIYVUNDZ2xpTjFuLU9haVlKYlpWOGd5cE5BGq4BRWdsd2JHRjViR2x6ZEhNZ0FUQUJPQUZnQVdvQWVtWlJWV3hRWVRGck5WSXlWa2hPVlUwMFUzcG9jMDFXWjNSV1ZsSkVaRlphZGxSRlVYUmllbVJ0VWxkck0wOVlTblZrYXpsMFVsaGFhR1JXVGxCVk0wNW9UbFJrYmxSSFRuTlJiazVEVkcxYWJHSnRXWGRTVmtaMldXMVZkRlJVYkc5a1YzaEZUV2U0QVFBJTNE" aria-label="Load more " onclick=";return false;" type="button">
    <span class="yt-uix-button-content">
      <span class="load-more-loading hid">
        <span class="yt-spinner"></span>
          <span class="load-more-text"> Load more </span>
        </span>
      </span>
    </span>
 </button>

So , is there any ways of clicking on this button so that i can load the remaining playlist items using mechanize gem ?

Thank you.

Pardeep Dhingra
  • 3,916
  • 7
  • 30
  • 56

1 Answers1

-1

Mechanize has support to click the button with click_button method.

You should be able to do this:

button = form.button_with(:id "foobar") # your criteria

form.click_button(button)

or you can call submit on the agent itself:

agent.submit(form, button)

If you don't have your button inside a form object, mechanize will probably not be able to work with it. You can check by looking at all buttons in the page object.

Drenmi
  • 8,492
  • 4
  • 42
  • 51
Rajesh Sharma
  • 419
  • 2
  • 5