Closed Bug 1097032 Opened 10 years ago Closed 9 years ago

Add test for expected.elements_present when there are no elements found

Categories

(Remote Protocol :: Marionette, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla36

People

(Reporter: Bebe, Assigned: davehunt)

References

Details

Attachments

(1 file, 1 obsolete file)

marionette.expected.elements_present should return False of there are no elements present on the page.

Instead it returns the result of the default result of the find_elements if there are no results on the page: a blank list.'[]'


See the docs:

Returns:	list of web elements once they are located, or False


http://marionette-client.readthedocs.org/en/latest/#marionette.expected.elements_present

see
The wait condition expects the condition to not False (but a boolean) or None, so an empty list will return early. There's also a missing test here.
Assignee: nobody → dave.hunt
Status: NEW → ASSIGNED
Attachment #8521380 - Flags: review?(ato)
Why would we expect a boolean type as a return value to this?  An empty list, [], is a value that evaluates to false.  So unless you're doing explicit type checking (which you shouldn't) in your test, when is this a problem?
Flags: needinfo?(dave.hunt)
(In reply to Andreas Tolfsen (:ato) from comment #3)
> Why would we expect a boolean type as a return value to this?  An empty
> list, [], is a value that evaluates to false.  So unless you're doing
> explicit type checking (which you shouldn't) in your test, when is this a
> problem?

The explicit type checking is happening in the Wait class: http://hg.mozilla.org/mozilla-central/file/default/testing/marionette/client/marionette/wait.py#l128 :)
Flags: needinfo?(dave.hunt)
(In reply to Dave Hunt (:davehunt) from comment #4)
> (In reply to Andreas Tolfsen (:ato) from comment #3)
> > Why would we expect a boolean type as a return value to this?  An empty
> > list, [], is a value that evaluates to false.  So unless you're doing
> > explicit type checking (which you shouldn't) in your test, when is this a
> > problem?
> 
> The explicit type checking is happening in the Wait class:
> http://hg.mozilla.org/mozilla-central/file/default/testing/marionette/client/
> marionette/wait.py#l128 :)

Hm.  Is that a reasonable assumption still?
assuming C5 was a question for you :)
Flags: needinfo?(dave.hunt)
(In reply to David Burns :automatedtester from comment #6)
> assuming C5 was a question for you :)

We discussed this on IRC and :davehunt filed bug 1103956 about removing the type check.  Fingers crossed we can get rid of it.

:davehunt, should that bug be a dependency for this one, or do you want to land this patch as it is?
Flags: needinfo?(dave.hunt)
Flags: needinfo?(dave.hunt)
We don't need this fix if bug 1103956 sticks, however there is a missing test this patch adds. I've added the dependency and will update the patch and bug summary once it's unblocked.
Depends on: 1103956
Flags: needinfo?(dave.hunt)
Summary: marionette.expected.elements_present is returning a blank list if there are no elements present → Add test for expected.elements_present when there are no elements found
Attachment #8528643 - Flags: review?(ato) → review+
https://hg.mozilla.org/mozilla-central/rev/b6e09893ea97
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla36
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.