RSelenium cannot access DOM

拟墨画扇 提交于 2019-12-08 08:01:32

问题


I am using Selenium on Stockpair Website

s = remoteDriver(remoteServerAddr = "localhost", port = 4444, browserName = "chrome")
s$open()
url <- "https://www.stockpair.com/sp#trading/page"
s$navigate(url)
dir <- s$findElement("css selector", "div.stockSelectionButton.left")
dir$clickElement()

I get the error

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

I researched that it happens if the DOM changes by an asynchronous process. However, I tested with Selenium running chrome.exe visible and the DOM doesnt change and th element is still there after loading the page.

Can there be other causes?


回答1:


This is quite a dynamic site with periodical updates which change the DOM.

Click the element via JavaScript:

s$executeScript("arguments[0].click();", list(dir))

Also see:

  • WebDriver click() vs JavaScript click()


来源:https://stackoverflow.com/questions/34925320/rselenium-cannot-access-dom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!