Closed Bug 864296 Opened 7 years ago Closed 7 years ago

Marionette webelement.find_element(locator) returns values even if the webelement is no longer present on the page

Categories

(Testing :: Marionette, defect)

defect
Not set

Tracking

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

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

People

(Reporter: Bebe, Assigned: jgriffin)

References

Details

Attachments

(2 files)

Attached file Test for the bug
This is a little complicated.

1. Store a webelement in a variable
2. delete the webelement from the page
3. call the stored webelement from the var and check it's properties 

Espected:
3. calling properties for a webelement that doesn’t exist should return a exception NoSuchElementException or something similar

Actual:
3. calling the webelement returns false positive data


Here is the code:

        #store a web element in a var
        element = self.marionette.find_element(*self._favorite_list_locator)


        # check some basic properties
        print element.is_displayed()
        print element.text
        print element.find_element(*self._remove_locator).is_displayed()
        self.assertTrue(element.find_element(*self._remove_locator))
        
        print "======================"
        print "delete the element"

        #delete the web element
        self.marionette.tap(element.find_element(*self._remove_locator))
        time.sleep(2)

        print "element is deleted"
        print "====================="

        # call the same properties. This methods should return exceptions
        print element.is_displayed() 
        print element.text
        print element.find_element(*self._remove_locator).is_displayed()
        self.assertTrue(element.find_element(*self._remove_locator))

        #searching for the same element again returns a error
        self.marionette.find_element(*self._favorite_list_locator)


I have added in the attachment the full test
Webdriver returns a StaleElementReferenceException

selenium.common.exceptions.StaleElementReferenceException: Message: u'Element is no longer attached to the DOM'

selenium test: https://gist.github.com/bebef1987/5434882
http://hg.mozilla.org/mozilla-central/file/ea3ffdbddc53/testing/marionette/marionette-elements.js#l108

We check if the element is no longer a part of the document, but I suppose if GC hasn't run yet, perhaps it still is part of the document. The way the element is being removed is :

https://github.com/mozilla-b2g/gaia/blob/master/apps/fm/js/fm.js#L588

that is, we should be checking its parentNode to see if it is not null.
Blocks: 801898
Summary: Marionette webelement.find_element(locator) retuns values even if the webelement is no longer pressent on the page → Marionette webelement.find_element(locator) returns values even if the webelement is no longer present on the page
Assignee: nobody → jgriffin
Attachment #740252 - Attachment mime type: text/x-python → text/plain
Attachment #743956 - Flags: review?(mdas)
Comment on attachment 743956 [details] [diff] [review]
Check for detached elements,

Review of attachment 743956 [details] [diff] [review]:
-----------------------------------------------------------------

Ah, cool, this should do it
Attachment #743956 - Flags: review?(mdas) → review+
https://hg.mozilla.org/mozilla-central/rev/d846f95bc761
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Keywords: checkin-needed
You need to log in before you can comment on or make changes to this bug.