Skip to content

Commit

Permalink
Altered CP commit to enable spec to work
Browse files Browse the repository at this point in the history
fix disable implicit waits for elements as well
  • Loading branch information
luke-hill committed Jul 4, 2018
1 parent 23b15cd commit 1db32b5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
7 changes: 6 additions & 1 deletion features/explicit_waiting.feature
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ Feature: Waiting for Elements
And I remove the parent section of the element
Then I receive an error when a section with the element I am waiting for is removed

Scenario: Elements Are Not Waited For
Scenario: Element Is Not Automatically Waited For
When I navigate to the home page
Then the slow element is not waited for
And implicit waits are not enabled

Scenario: Elements Collections Are Not Automatically Waited For
When I navigate to the home page
Then the slow elements are not waited for
And implicit waits are not enabled
9 changes: 7 additions & 2 deletions features/implicit_waiting.feature
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
@implicit_waits
Feature: Waiting for Elements
Feature: Waiting for Elements Implicitly

I want to be able to implicitly wait for an element
In order to interact with the element once it is ready

Scenario: Elements Are Waited For
Scenario: Elements Are Automatically Waited For
When I navigate to the home page
Then the slow element is waited for
And implicit waits are enabled

Scenario: Elements Collections Are Automatically Waited For
When I navigate to the home page
Then the slow elements are waited for
And implicit waits are enabled
17 changes: 16 additions & 1 deletion features/step_definitions/wait_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,27 @@

Then(/^the slow element is not waited for$/) do
start_time = Time.now
@test_site.home.some_slow_element

expect { @test_site.home.some_slow_element }.to raise_error(Capybara::ElementNotFound)

expect(Time.now - start_time).to be < 0.5
end

Then(/^the slow element is waited for$/) do
start_time = Time.now
@test_site.home.some_slow_element

expect(Time.now - start_time).to be > 1.5
end

Then(/^the slow elements are waited for$/) do
start_time = Time.now
@test_site.home.slow_elements(count: 1)
expect(Time.now - start_time).to be > 1.5
end

Then(/^the slow elements are not waited for$/) do
start_time = Time.now
expect { @test_site.home.slow_elements(count: 1) }.to raise_error(Capybara::ElementNotFound)
expect(Time.now - start_time).to be < 0.5
end
1 change: 1 addition & 0 deletions test_site/pages/home.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class TestHomePage < SitePrism::Page
elements :welcome_headers, :xpath, '//h3'
elements :welcome_messages, :xpath, '//span'
elements :rows, 'td'
elements :slow_elements, :xpath, '//a[@class="slow"]' # note - actually only one

# elements that should not exist
element :squirrel, 'squirrel.nutz'
Expand Down

0 comments on commit 1db32b5

Please sign in to comment.