Skip to content

Commit

Permalink
[rb] still not waiting long enough for tests to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed May 25, 2022
1 parent 37be1da commit 0d6a695
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
6 changes: 3 additions & 3 deletions rb/spec/integration/selenium/webdriver/action_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ module WebDriver
delta_y = footer.rect.y

driver.action.scroll_by(0, delta_y).perform
sleep 0.2
sleep 0.5

expect(in_viewport?(footer)).to eq true
end
Expand All @@ -338,7 +338,7 @@ module WebDriver
driver.action.scroll_from(scroll_origin, 0, 200).perform

driver.switch_to.frame(iframe)
sleep 0.2
sleep 0.5
checkbox = driver.find_element(name: 'scroll_checkbox')
expect(in_viewport?(checkbox)).to eq true
end
Expand All @@ -349,7 +349,7 @@ module WebDriver
scroll_origin = WheelActions::ScrollOrigin.element(footer, 0, -50)

driver.action.scroll_from(scroll_origin, 0, 200).perform
sleep 0.2
sleep 0.5

iframe = driver.find_element(tag_name: 'iframe')
driver.switch_to.frame(iframe)
Expand Down
5 changes: 5 additions & 0 deletions rb/spec/integration/selenium/webdriver/element_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,34 +45,39 @@ module WebDriver
driver.navigate.to url_for('formPage.html')
driver.find_element(id: 'submitButton').submit

wait_for_new_url('formPage.html')
expect(driver.title).to eq('We Arrive Here')
end

it 'any input element in form' do
driver.navigate.to url_for('formPage.html')
driver.find_element(id: 'checky').submit

wait_for_new_url('formPage.html')
expect(driver.title).to eq('We Arrive Here')
end

it 'any element in form' do
driver.navigate.to url_for('formPage.html')
driver.find_element(css: 'form > p').submit

wait_for_new_url('formPage.html')
expect(driver.title).to eq('We Arrive Here')
end

it 'button with id submit' do
driver.navigate.to url_for('formPage.html')
driver.find_element(id: 'submit').submit

wait_for_new_url('formPage.html')
expect(driver.title).to eq('We Arrive Here')
end

it 'button with name submit' do
driver.navigate.to url_for('formPage.html')
driver.find_element(name: 'submit').submit

wait_for_new_url('formPage.html')
expect(driver.title).to eq('We Arrive Here')
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ def wait_for_element(locator)
wait.until { driver.find_element(locator) }
end

def wait_for_new_url(old_url)
wait = Wait.new(timeout: 5)
wait.until do
url = driver.current_url
!(url.empty? || url.include?(old_url))
end
end

def wait(timeout = 10)
Wait.new(timeout: timeout)
end
Expand Down

0 comments on commit 0d6a695

Please sign in to comment.