在运行机器人框架测试时,随机获取“元素不再附加到DOM”

时间:2015-08-05 08:34:09

标签: selenium testing selenium-webdriver robotframework

我有一个用Robot Framework编写的测试,它运行在我的应用程序的基于Web的用户界面上。问题是随机时间脚本无法访问Web元素并引发此错误:

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)

我用谷歌搜索,我发现它与我的等待有关。有时在我的代码中,我等待一个元素可见,然后点击它:

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

我认为DOM实际上有时会改变这两个命令之间的Web元素;但我不知道如何避免这种情况?

0 个答案:

没有答案