1

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?

user670186
  • 2,588
  • 6
  • 37
  • 55

1 Answers1

4

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:

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • thanks but with your code I get Error: Summary: UnknownError Detail: An unknown server-side error occurred while processing the command. class: org.openqa.selenium.remote.JsonException In addition: There were 28 warnings (use warnings() to see them) – user670186 Jan 21 '16 at 15:10
  • this works: s$executeScript("$('div.stockSelectionButton.left').click();", args = list()) – user670186 Jan 21 '16 at 15:14
  • @user670186 ah, forgot to call the list, please retest. Thanks. – alecxe Jan 21 '16 at 15:18