Created
June 2, 2017 07:54
-
-
Save patorash/2591e34809c34a8168689eb2185f0275 to your computer and use it in GitHub Desktop.
Capybara::Node::Actionsを開いて、click_linkとclick_buttonで例外が発生したらtriggerを使って処理を行うようにしてみた
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Capybara | |
module Node | |
module Actions | |
def new_click_button(locator=nil, options={}) | |
locator, options = nil, locator if locator.is_a? Hash | |
begin | |
find(:button, locator, options).click | |
rescue Capybara::Poltergeist::MouseEventFailed => e | |
find(:button, locator, options).trigger('click') | |
end | |
end | |
def new_click_link(locator=nil, options={}) | |
locator, options = nil, locator if locator.is_a? Hash | |
begin | |
find(:link, locator, options).click | |
rescue Capybara::Poltergeist::MouseEventFailed => e | |
find(:link, locator, options).trigger('click') | |
end | |
end | |
alias_method :old_click_button, :click_button | |
alias_method :click_button, :new_click_button | |
alias_method :old_click_link, :click_link | |
alias_method :click_link, :new_click_link | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BOND GATEはTurnipのweb_stepの中で次のようにクリックしてる。
なので、click_buttonやclick_linkは使ってないことになる。
first(:link, link)
はCapybara::Node:Elementクラスなので次のようにclickをこじ開けて対応。...しようかと思ったんだけど再現性が無いので検証もできずちょっとためらってる。
BOND GATEで
Capybara::Poltergeist::MouseEventFailed
が出ない気がするのは、きっとrspec-retry.gemが入ってるから。