Closed Bug 944322 Opened 8 years ago Closed 4 years ago
For Element cannot wait for a element not in the DOM yet .
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?
We could see the function in https://github.com/mozilla-b2g/marionette-helper/blob/master/index.js#L124-L129.
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.
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  documented by the Python client . Those methods are all private; the public `findElement` and `findElements` are defined in `marionette-server.js` , 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` . 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.  https://mxr.mozilla.org/mozilla-central/source/testing/marionette/marionette-elements.js#301  https://marionette_client.readthedocs.org/en/latest/#marionette.Marionette.find_element  https://mxr.mozilla.org/mozilla-central/source/testing/marionette/marionette-server.js  https://github.com/mozilla-b2g/marionette-helper/blob/ccb7c443598e8dc4bbd058fa17f6acfe7b9da068/index.js#L127-L129
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
Bulk closed as part of https://bugzilla.mozilla.org/show_bug.cgi?id=1422750
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.