我使用selenium驱动程序使用带有Ruby 1.9.3的Capybara,以便从网站上获取信息.点击几页后我访问了我想要的页面并放入:
all(:css, 'td').each { |td| a_info << td }
a_info.each {|t| puts t.text }
Run Code Online (Sandbox Code Playgroud)
我等了大约10秒后得到的错误:
[remote server] resource://fxdriver/modules/web_element_cache.js:5628:in `unknown': Element not found in the cache - perhaps the page has changed since it was looked up (Selenium::WebDriver::Error::StaleElementReferenceError)
Run Code Online (Sandbox Code Playgroud)
跟着更多的远程服务器错误.我给了页面10-30秒的睡眠时间,它仍然没有加载,当我打印page.html时,我看到一个javascript脚本,然后我正在尝试从中获取信息的所有td.我知道错误意味着找到的元素不是当前元素,但似乎已经加载了所有元素,所以我不确定它们为什么不再存在.我已经在互联网上搜索了几个小时寻找这个,并希望从可能的解决方案中获得任何帮助,尝试下一步尝试解决这个问题.我可以提供所需的任何额外信息,请告诉我.