Commit a1a45827 authored by Michael Kozono's avatar Michael Kozono

Fix intermittently failed click in dropdown

I haven’t seen `go_to_new_subgroup` fail in the same way, but it seems best to modify it also.
parent 6c978c8f
...@@ -13,16 +13,18 @@ module QA ...@@ -13,16 +13,18 @@ module QA
visit current_url visit current_url
end end
def wait(css = '.application', time: 60) def wait(max: 60, time: 1, reload: true)
Time.now.tap do |start| start = Time.now
while Time.now - start < time
break if page.has_css?(css, wait: 5)
refresh while Time.now - start < max
end return true if yield
sleep(time)
refresh if reload
end end
yield if block_given? false
end end
def scroll_to(selector, text: nil) def scroll_to(selector, text: nil)
......
...@@ -25,7 +25,12 @@ module QA ...@@ -25,7 +25,12 @@ module QA
def go_to_new_subgroup def go_to_new_subgroup
within '.new-project-subgroup' do within '.new-project-subgroup' do
# May need to click again because it is possible to click the button quicker than the JS is bound
wait(reload: false) do
find('.dropdown-toggle').click find('.dropdown-toggle').click
page.has_css?("li[data-value='new-subgroup']")
end
find("li[data-value='new-subgroup']").click find("li[data-value='new-subgroup']").click
end end
...@@ -34,7 +39,12 @@ module QA ...@@ -34,7 +39,12 @@ module QA
def go_to_new_project def go_to_new_project
within '.new-project-subgroup' do within '.new-project-subgroup' do
# May need to click again because it is possible to click the button quicker than the JS is bound
wait(reload: false) do
find('.dropdown-toggle').click find('.dropdown-toggle').click
page.has_css?("li[data-value='new-project']")
end
find("li[data-value='new-project']").click find("li[data-value='new-project']").click
end end
......
...@@ -10,12 +10,14 @@ module QA ...@@ -10,12 +10,14 @@ module QA
view 'app/views/devise/sessions/_new_base.html.haml' do view 'app/views/devise/sessions/_new_base.html.haml' do
element :login_field, 'text_field :login' element :login_field, 'text_field :login'
element :passowrd_field, 'password_field :password' element :password_field, 'password_field :password'
element :sign_in_button, 'submit "Sign in"' element :sign_in_button, 'submit "Sign in"'
end end
def initialize def initialize
wait('.application', time: 500) wait(max: 500) do
page.has_css?('.application')
end
end end
def sign_in_using_credentials def sign_in_using_credentials
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment