Created
March 24, 2017 14:52
-
-
Save sevos/9727dd876a14339e13fdbb328ebd6044 to your computer and use it in GitHub Desktop.
This is a helper simulating mouse events related to hovering over an element: onmouseenter onmouseleave etc.
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
require 'rails_helper' | |
RSpec.feature 'Feature', js: true do | |
include InteractionHelper | |
scenario 'Scenario' do | |
visit '/' | |
hover_mouse(find('div#id')) do | |
click_on 'Button' | |
end | |
end | |
end |
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 InteractionHelper | |
def hover_mouse(element) | |
page.driver.browser.action.move_to(element.native, -1, -1).perform | |
page.driver.browser.action.move_to(element.native, 1, 1).perform | |
element.hover | |
within(element) do | |
yield | |
end | |
page.driver.browser.action.move_to(element.native, 1, 1).perform | |
page.driver.browser.action.move_to(element.native, -1, -1).perform | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment