Skip to content
Open
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
8 changes: 8 additions & 0 deletions lib/ae_page_objects/element_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ def method_missing(name, *args, &block)
end

implicit_element.__send__(name, *args, &block)
rescue AePageObjects::LoadingElementFailed
raise unless %w(to_s inspect).include? name.to_s

# The element is being serialized for debug / warning purposes. In
# this situation it is a valid case that the element may not exist so
# instead of raising an error just return a string indicating that the
# element does not exist.
'[element not found]'
end

def respond_to?(*args)
Expand Down
12 changes: 12 additions & 0 deletions test/unit/element_proxy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@ def test_absent__element_not_found
assert proxy.absent?(wait: 20)
end

def test_inspect__element_not_found
proxy = new_proxy
element_class.expects(:new).raises(AePageObjects::LoadingElementFailed)
assert_equal '[element not found]', proxy.inspect
end

def test_to_s__element_not_found
proxy = new_proxy
element_class.expects(:new).raises(AePageObjects::LoadingElementFailed)
assert_equal '[element not found]', proxy.to_s
end

def test_presence
proxy = new_proxy

Expand Down