Refactor "I scroll" web step to avoid using execute_script
The apparition driver does not support "scroll_by" without going through "execute_script", but we can better express the intention of this test and make the scrolling action a bit more general by replacing "scroll a bit" with "scroll to [some element]" — in this case, we need to scroll until the "Change" button is visible so that we can press it. This change_settings.feature spec is the only place that used "I scroll a bit".
This commit is contained in:
parent
e5b65f6498
commit
df4504979e
3 changed files with 7 additions and 6 deletions
|
|
@ -19,12 +19,12 @@ Feature: Change settings
|
||||||
|
|
||||||
Scenario: Change my email preferences
|
Scenario: Change my email preferences
|
||||||
When I uncheck "user_email_preferences_mentioned"
|
When I uncheck "user_email_preferences_mentioned"
|
||||||
And I scroll a bit
|
And I scroll to "change_email_preferences"
|
||||||
And I press "change_email_preferences"
|
And I press "change_email_preferences"
|
||||||
Then I should see "Email notifications changed"
|
Then I should see "Email notifications changed"
|
||||||
And the "user_email_preferences_mentioned" checkbox should not be checked
|
And the "user_email_preferences_mentioned" checkbox should not be checked
|
||||||
When I uncheck "user_email_preferences_mentioned_in_comment"
|
When I uncheck "user_email_preferences_mentioned_in_comment"
|
||||||
And I scroll a bit
|
And I scroll to "change_email_preferences"
|
||||||
And I press "change_email_preferences"
|
And I press "change_email_preferences"
|
||||||
Then I should see "Email notifications changed"
|
Then I should see "Email notifications changed"
|
||||||
And the "user_email_preferences_mentioned_in_comment" checkbox should not be checked
|
And the "user_email_preferences_mentioned_in_comment" checkbox should not be checked
|
||||||
|
|
|
||||||
|
|
@ -167,10 +167,6 @@ Then /^I should see (\d+) contacts$/ do |n_posts|
|
||||||
has_css?("#people-stream .stream-element", count: n_posts.to_i).should be true
|
has_css?("#people-stream .stream-element", count: n_posts.to_i).should be true
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^I scroll a bit$/ do
|
|
||||||
page.execute_script("window.scrollBy(0,200)")
|
|
||||||
end
|
|
||||||
|
|
||||||
And /^I scroll down$/ do
|
And /^I scroll down$/ do
|
||||||
page.execute_script("window.scrollBy(0,3000000)")
|
page.execute_script("window.scrollBy(0,3000000)")
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -195,3 +195,8 @@ Then /^I wait until ajax requests finished$/ do
|
||||||
loop until page.evaluate_script("jQuery.active") == 0
|
loop until page.evaluate_script("jQuery.active") == 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
When /^I scroll to "([^"]*)"$/ do |element_id|
|
||||||
|
element = find_by_id(element_id) # rubocop:disable Rails/DynamicFindBy
|
||||||
|
page.scroll_to(element, align: :bottom)
|
||||||
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue