2

This one is a little obscure admittedly. What I'm trying to do is access highchart data from a selenium driven chrome instance via driver.execute_script method and passing in javascript:

driver.execute_script("return $('#chartID').highcharts().series[0].data")

Selenium raises an error Selenium::WebDriver::Error::UnknownError unknown error: Maximum call stack size exceeded

driver.execute_script("return $('#chartID').highcharts()")
driver.execute_script("return Highcharts.charts")

Both return the same error.

It should be noted that both of these javascript lines work in dev console in a non selenium instance of chrome.

This is the guide that I'm using: http://ahumbleopinion.com/highcharts-tips-accessing-chart-object-from-container-id/

Kylee
  • 1,625
  • 1
  • 31
  • 54
  • You should create a jsbin or a jsfiddle that reproduces the problem. – Louis Apr 29 '15 at 22:15
  • 1
    Not possible as the selenium script is ruby, its running an instance of chrome and passing the javascript to it to execute. – Kylee Apr 30 '15 at 14:12
  • Let me spell it out. 1. Create a jsbin or a jsfiddle that is set so that when you run a Ruby script that replicates the pertinent parts of to your complete script against this jsbin or jsfiddle, you get the same behavior as what you are reporting in your question. 2. Paste the smaller Ruby script that replicate the issue (created in 1 above) into your question. This is by no means impossible. – Louis Apr 30 '15 at 14:19
  • 1
    I don't think that jsbin/jsfiddle with help here. Lets say I do setup a jsfiddle with a link to the highcharts lib and I have you the one line of ruby that's trying to execute `driver.execute_script("return Highcharts")` this wouldn't be helpful unless you have the ruby selenium gem installed and able to test against the jsfiddle's output page. My guess is that its an issue of size, it can't handle the size of the data being returned from the execute_script call. At least this is what I've been able to find online. – Kylee Apr 30 '15 at 14:49

2 Answers2

4

So essentially how I got around this was simply reducing the amount of data returned from execute_script by using the reduce function on data array Highcharts was returning.

driver.execute_script <<-js
  return Highcharts
           .charts[0]
           .series[0]
           .data
           .map(function (data) { return data.y })
js
Kylee
  • 1,625
  • 1
  • 31
  • 54
-2

Ruby 1.9.x and later use a VM that has its own stack. In Ruby 2.0.0 and later, the size of the VM stack can be controlled via the RUBY_THREAD_VM_STACK_SIZE environment variable.

To set the environment variable, go to System property -> Advance tab -> Environment Variable.

Reference How to increase stack size for a ruby app. Recursive app getting: Stack level too deep (SystemStackError)

Community
  • 1
  • 1
TsengnesT
  • 1
  • 1
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – sergdenisov Aug 26 '15 at 19:53
  • Cool, will remember that next time. :) – TsengnesT Aug 26 '15 at 21:29