Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby Rails:如何使用Mechanize gem单击按钮?_Ruby_Ruby On Rails 4_Mechanize Ruby - Fatal编程技术网

Ruby Rails:如何使用Mechanize gem单击按钮?

Ruby Rails:如何使用Mechanize gem单击按钮?,ruby,ruby-on-rails-4,mechanize-ruby,Ruby,Ruby On Rails 4,Mechanize Ruby,我正在尝试使用Mechanizegem在用户播放列表部分点击youtube的Load more按钮。但问题是,在我的Rails应用程序中,我找不到使用mechanizegem单击按钮的任何方法 我想点击的按钮的html代码如下: <button class="yt-uix-button yt-uix-button-size-default yt-uix-button-default load-more-button yt-uix-load-more browse-items-load-mo

我正在尝试使用
Mechanize
gem在用户播放列表部分点击youtube的
Load more
按钮。但问题是,在我的
Rails
应用程序中,我找不到使用mechanizegem单击
按钮的任何方法

我想点击的按钮的
html
代码如下:

<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>

加载更多
那么,有没有办法点击这个按钮,这样我就可以使用mechanize gem加载剩余的播放列表项


谢谢。

Mechanize支持使用方法单击按钮

您应该能够做到这一点:

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

form.click_button(button)
或者,您可以在代理本身上调用submit:

agent.submit(form, button)
如果表单对象中没有按钮,
mechanize
可能无法使用它。您可以通过查看
页面
对象中的所有按钮进行检查