Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Version 2.0.0

### Added

* [111](https://github.com/appfolio/ae_page_objects/issues/111) Adding wait: option to all polling query methods.

### Changed

* [176](https://github.com/appfolio/ae_page_objects/pull/176) Limit exposed constants to _public_ API.
Expand Down
16 changes: 8 additions & 8 deletions lib/ae_page_objects/element_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,29 @@ def initialize(element_class, *args)
@loaded_element = nil
end

def visible?
wait_until_visible
def visible?(options = {})
wait_until_visible(options[:wait])
true
rescue ElementNotVisible
false
end

def hidden?
wait_until_hidden
def hidden?(options = {})
wait_until_hidden(options[:wait])
true
rescue ElementNotHidden
false
end

def present?
wait_until_present
def present?(options = {})
wait_until_present(options[:wait])
true
rescue ElementNotPresent
false
end

def absent?
wait_until_absent
def absent?(options = {})
wait_until_absent(options[:wait])
true
rescue ElementNotAbsent
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,10 @@ def test_multiple_paths_visit
def test_element_proxy
author = PageObjects::Authors::NewPage.visit

Capybara.using_wait_time(1) do
assert author.rating.star.present?
assert author.rating.star.visible?
refute author.rating.star.absent?
refute author.rating.star.hidden?
end
assert author.rating.star.present?(wait: 1)
assert author.rating.star.visible?(wait: 1)
refute author.rating.star.absent?(wait: 1)
refute author.rating.star.hidden?(wait: 1)

assert_nothing_raised do
author.rating.star.wait_until_present(0)
Expand Down
17 changes: 13 additions & 4 deletions test/unit/element_proxy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ def test_visible
element_class.expect_new
element_class.any_instance.expects(:visible?).returns(true)
assert proxy.visible?
end

def test_visible__false
proxy = new_proxy
element_class.expect_new
element_class.any_instance.expects(:visible?).returns(true)
assert proxy.visible?(wait: 20)

element_class.expect_new
element_class.any_instance.expects(:visible?).returns(false)
Expand All @@ -65,6 +65,10 @@ def test_hidden
element_class.any_instance.expects(:visible?).returns(false)
assert proxy.hidden?

element_class.expect_new
element_class.any_instance.expects(:visible?).returns(false)
assert proxy.hidden?(wait: 20)

element_class.expect_new
element_class.any_instance.expects(:visible?).returns(true)
assert ! proxy.hidden?
Expand All @@ -82,6 +86,9 @@ def test_present

element_class.expect_new
assert proxy.present?

element_class.expect_new
assert proxy.present?(wait: 20)
end

def test_present__element_not_found
Expand All @@ -95,7 +102,6 @@ def test_absent
proxy = new_proxy

element_class.expect_new

refute proxy.absent?
end

Expand All @@ -104,6 +110,9 @@ def test_absent__element_not_found

element_class.expects(:new).raises(AePageObjects::LoadingElementFailed)
assert proxy.absent?

element_class.expects(:new).raises(AePageObjects::LoadingElementFailed)
assert proxy.absent?(wait: 20)
end

def test_presence
Expand Down