Closed Bug 830197 Opened 11 years ago Closed 11 years ago

Marionette not waiting long enough before send_keys

Categories

(Remote Protocol :: Marionette, defect)

x86
macOS
defect
Not set
normal

Tracking

(firefox23 fixed, b2g18 fixed, b2g18-v1.0.0 wontfix, b2g18-v1.0.1 fixed)

RESOLVED FIXED
mozilla23
Tracking Status
firefox23 --- fixed
b2g18 --- fixed
b2g18-v1.0.0 --- wontfix
b2g18-v1.0.1 --- fixed

People

(Reporter: bsilverberg, Assigned: automatedtester)

References

Details

Attachments

(3 files)

We are experiencing intermittent failures with a test for the Clock app on Firefox OS and have narrowed it down to a problem with calling send_keys on an element immediately after finding it.

I have attached a reduced test case to this bug. Running this I am able to generate a failure within 5 iterations most of the time.
Note that I tried to create a reduced test case using the UI Tests app, and was unable to replicate the problem with that.
Attachment #701654 - Attachment is patch: true
Attachment #701654 - Attachment mime type: text/x-python-script → text/plain
Comment on attachment 701654 [details]
Test case for send_keys issue

The attachment is not a patch. I'm sure Bob could make it a patch though if that makes it easier.
Attachment #701654 - Attachment is patch: false
What is the error you see when this happens?
There is no error message per se. The input field is not updated via the send_keys. 

Specifically with the test case attached, it is launching Clock, creating a new alarm, and trying to type in the Alarm Label field. Sometimes it works and the text that we specify _is_ entered into the Alarm Label field, but sometimes the field is not updated. The attached test case uses a loop to try this over and over again, and an assert to check whether the input was populated. If the assert fails this indicates that the send_keys failed and the input was not populated.  Note that we can see this happening on the device when we watch, so it's not just an issue of element.get_attribute('value') not picking up the change - the send_keys does appear to be failing to populate the field.
Now I look at this closely I think it might be just the timing after the asynchronous tap, a problem we have experienced with other tests when using tap().. 

but I also know that marionette suffers from is_displayed problems in this app and that you can't easily wait for elements in this test.
This passes every time for me if I add a wait for the alarm label element to be displayed (see below). We could enhance the implicit wait when locating elements to wait for the element to be displayed, but I would generally prefer such an explicit wait.

self.wait_for_condition(lambda m: alarm_label.is_displayed())
Status: NEW → RESOLVED
Closed: 11 years ago
Flags: needinfo?(bob.silverberg)
Resolution: --- → WORKSFORME
Ok, so you're saying that if we wait for the element to be displayed, rather than just finding it, then it works. That's fine with me for a workaround, but I believe that we raised this issue because we thought that Marionette shouldn't behave the way it does. If we use send_keys to populate a field and the field is not populated, should we get back an error, or is it ok for it to just fail silently as it is doing in this case?
Flags: needinfo?(bob.silverberg)
I think if we try to interact with an element that is not displayed, Marionette should probably fail. I've seen this before so maybe this is another use case. I'm happy for this to be reopened, but think the wait would still be needed in the test.
I am seeing the same behaviour with the awesome bar in the browser. The attached test case fails intermittently because the send_keys is happening before the element is visible. It doesn't update the awesome bar, but also doesn't throw an exception. If I add a wait_for_element_visible before trying to send_keys then it passes every time.

I believe the issue here is that if the element isn't visible and therefore cannot have keys sent to it, calling send_keys should throw an exception.
Status: RESOLVED → REOPENED
Resolution: WORKSFORME → ---
Assignee: nobody → dburns
Attachment #736721 - Flags: review?(mdas)
Attachment #736721 - Flags: review?(mdas) → review+
https://hg.mozilla.org/mozilla-central/rev/82ee824d2ffb
Status: REOPENED → RESOLVED
Closed: 11 years ago11 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla23
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: