Selenium message:stale元素参考:元素未附加到页面文档

时间:2019-11-30 17:47:04

标签: r selenium rselenium

我想从Rselenium的Google搜索中提取匹配的链接。我无法克服这个错误,有人可以指出我在做什么错,如何解决呢? 示例:

library("RSelenium")    
google <- "https://www.google.com"    
driver <- rsDriver(browser = c("chrome"),chromever = "78.0.3904.105")    
remote <- driver$client    
remote$navigate(google)    
google_query <- remote$findElement("name","q")    
google_query$sendKeysToElement(sendKeys = list('error stackoverflow'))    
google_query$submitElement()    
results <- google_query$findElements(using = "class",value = "iUh30")    
link <- results[[1]]    
link <- link$getElementText()
## here i was expecting url

错误:

Selenium message:stale element reference: element is not attached to the page document
  (Session info: chrome=78.0.3904.108)
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/stale_element_reference.html
Build info: version: '4.0.0-alpha-2', revision: 'f148142cf8', time: '2019-07-01T21:30:10'

Driver info: driver.version: unknown

Error:   Summary: StaleElementReference
     Detail: An element command failed because the referenced element is no longer attached to the DOM.
     class: org.openqa.selenium.StaleElementReferenceException
     Further Details: run errorDetails method

谢谢。

编辑:以澄清问题。结果不是empyt,我得到了DOM元素列表,但是当我尝试访问其中的文本时,出现了上面的错误。

0 个答案:

没有答案