Closed Bug 944322 Opened 11 years ago Closed 6 years ago

[marionette-helper] waitForElement cannot wait for a element not in the DOM yet.

Categories

(Testing Graveyard :: JSMarionette, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: evanxd, Unassigned)

Details

Hi all,

The waitForElement function cannot wait for a element not in the DOM yet.
Currently, if we wait for a element not in the DOM, we will get the error message "NoSuchElement: (7) Unable to locate element: ".

It is useful to wait for a element from it is not in the DOM yet until it is displayed.
How do you guys think?
Summary: [marionette-helper] waitForElement cannot wait for a element doesn't exist yet. → [marionette-helper] waitForElement cannot wait for a element not in the DOM yet.
If you guys think it is useful, we could let the waitForElement function do this thing.
Flags: needinfo?(gaye)
Flags: needinfo?(jlal)
Flags: needinfo?(mike)
So mhenretty ran into similar things but I think this is either a logic bug somewhere in our tests/client/marionette server... In theory marionette _should_ wait until the element is found in the DOM.

See: https://mxr.mozilla.org/mozilla-central/source/testing/marionette/marionette-elements.js#275

Lets fix the problem at the server level if there is an issue.
Flags: needinfo?(jlal) → needinfo?(mhenretty)
Evan: the source file James shared confused me a bit, so I want to share what I've learned in case it helps.

That file is a bit confusing because it defines `findElement`, and `findElements` methods, but only the `find` method implements the retry/timeout logic [1] documented by the Python client [2]. Those methods are all private; the public `findElement` and `findElements` are defined in `marionette-server.js` [3], and *those* implementations use the private `find` method that James originally linked to.

Given that, one would expect the `marionette-helper` plugin's `waitForElement` method to exhibit similar retry/timeout behavior since it uses `findElement` [4]. I tend to agree with James about there being a bug in the server itself, and I also think it makes the most sense to fix the root cause.

[1] https://mxr.mozilla.org/mozilla-central/source/testing/marionette/marionette-elements.js#301
[2] https://marionette_client.readthedocs.org/en/latest/#marionette.Marionette.find_element
[3] https://mxr.mozilla.org/mozilla-central/source/testing/marionette/marionette-server.js
[4] https://github.com/mozilla-b2g/marionette-helper/blob/ccb7c443598e8dc4bbd058fa17f6acfe7b9da068/index.js#L127-L129
Flags: needinfo?(mike)
The `waitForElement` marionette helper method will indeed wait for an element that is not yet in the DOM. At first, I thought `findElement` would immediately return a `NoSuchElement` error if the element was not in the DOM, but it turns out I just had my searchTimeout set too low. I wrote a test to verify this, so unless I am missing something I think this is working as intended:

https://github.com/mozilla-b2g/marionette-helper/blob/bcc09f3aa9acfa7485e6e80b79d1ccee6660fa0d/test/index_test.js#L37
Flags: needinfo?(mhenretty)
Flags: needinfo?(gaye)
Bulk closed as part of https://bugzilla.mozilla.org/show_bug.cgi?id=1422750
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → INCOMPLETE
Product: Testing → Testing Graveyard
You need to log in before you can comment on or make changes to this bug.