我正在运行Selenium webdriver Ruby脚本并且不一致地面对这个错误: -
[remote server] resource://fxdriver/modules/web_element_cache.js:7610:in `fxdriver.cache.getElementAt': Element not found in the cache - perhaps the page has changed since it was looked
up (Selenium::WebDriver::Error::StaleElementReferenceError)
from [remote server] file:///C:/Users/AKULKA~1/AppData/Local/Temp/webdriver-profile20140510-2952-10nsq50/extensions/fxdriver@googlecode.com/components/command_processor.js:7210:
in `Utils.getElementAt'
from [remote server] file:///C:/Users/AKULKA~1/AppData/Local/Temp/webdriver-profile20140510-2952-10nsq50/extensions/fxdriver@googlecode.com/components/command_processor.js:8223:
in `fxdriver.preconditions.visible'
from [remote server] file:///C:/Users/AKULKA~1/AppData/Local/Temp/webdriver-profile20140510-2952-10nsq50/extensions/fxdriver@googlecode.com/components/command_processor.js:10861
有时脚本会成功运行,有时会抛出此错误并失败。 我尝试添加等等但没有任何帮助。
可能出现什么问题?
以下是脚本失败的代码: -
# Go to Maintenance tab
wait.until {browser.find_element(:xpath,"/html/body/div[5]/div/div/div/div/div/div[2]/div[2]/div/div/div/table/tbody/tr/td[2]/div/div/table/tbody/tr/td[6]/a")}
browser.find_element(:xpath,"/html/body/div[5]/div/div/div/div/div/div[2]/div[2]/div/div/div/table/tbody/tr/td[2]/div/div/table/tbody/tr/td[6]/a").click
它不仅仅是这行代码,但有时候脚本会在另一行中失败而抛出相同的异常,有时候一切都运行得很好。 为何如此不一致?
提前谢谢你。 阿布舍克巴克