mercredi 5 août 2015

Randomly get "Element is no longer attached to the DOM" while running robot framework test

I have a test written in Robot Framework which runs over my application's Web-based User Interface. The problem is there are random times that the script can't access web elements and raise this error:

StaleElementReferenceException: Message: Element is no longer attached to the DOM
Stacktrace:
    at fxdriver.cache.getElementAt (resource://fxdriver/modules/web-element-cache.js:8984)
    at Utils.getElementAt (file:///c:/users/user/appdata/local/temp/tmp4xd_ww/webdriver-py-profilecopy/extensions/fxdriver@googlecode.com/components/command-processor.js:8574)
    at WebElement.getElementAttribute (file:///c:/users/user/appdata/local/temp/tmp4xd_ww/webdriver-py-profilecopy/extensions/fxdriver@googlecode.com/components/command-processor.js:11764)
    at DelayedCommand.prototype.executeInternal_/h (file:///c:/users/user/appdata/local/temp/tmp4xd_ww/webdriver-py-profilecopy/extensions/fxdriver@googlecode.com/components/command-processor.js:12282)
    at DelayedCommand.prototype.executeInternal_ (file:///c:/users/user/appdata/local/temp/tmp4xd_ww/webdriver-py-profilecopy/extensions/fxdriver@googlecode.com/components/command-processor.js:12287)
    at DelayedCommand.prototype.execute/< (file:///c:/users/user/appdata/local/temp/tmp4xd_ww/webdriver-py-profilecopy/extensions/fxdriver@googlecode.com/components/command-processor.js:12229)

I googled and I found out that it's related to my waits. Some times in my code, I wait for an element to be visible and then click on it:

wait until element is visible   xpath=//*[@id="UserTableForm:${defRow}:0"]/input   2
click element                   xpath=//*[@id="UserTableForm:${defRow}:0"]/input

I think some times the DOM actually changes the web elements between these two commands; but I don't know how to avoid that?

Aucun commentaire:

Enregistrer un commentaire