Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ElementProxy#not_present? does not wait for element to be absent. #65

Closed
dtognazzini opened this issue Aug 15, 2014 · 0 comments
Closed
Assignees

Comments

@dtognazzini
Copy link
Contributor

ElementProxy was introduced so the presence of elements on the page could be queried.

class SomePage < AePageObjects::Document
  element :some_element
end

some_page = SomePage.visit
some_page.some_element.present?

ElementProxy#present? accesses the element and retries on Capybara::ElementNotFound until Capybara.default_wait_time.

When the underlying element is found, it is cached so subsequent calls through ElementProxy don't incur another lookup.

ElementProxy#not_present? was intended to work the same way, whereby the underlying element is accessed and retries until it is no longer present (i.e. absent) on the page.

However, due to the element caching, if not_present? is called after the underlying element has been cached, the page is not polled for the absence of the element.

not_present? should work just like present? and poll the page until the underlying element is not present.

Additionally, the query methods present? and not_present? do not communicate to the reader that the page is polled and the presence or absence of the element is queried until achieved. In some tests, these methods are called with the intent of waiting and in others these methods are called with the intent of querying the state of the element.

With the intent of waiting:

modal = some_page.modal
do_modal_things(modal)
some_page.modal.not_present? 

With the intent of querying:

modal = some_page.modal
if modal.present?
   do_modal_things(modal)
end

While the underlying implementation should wait for the state in both cases, the methods called should reflect the intent.

The following reads much better:

With the intent of waiting:

modal = some_page.modal
do_modal_things(modal)
modal.wait_for_absence

With the intent of querying:

modal = some_page.modal
if modal.present?
   do_modal_things(modal)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant