Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: Read data from Highcharts after setExtreme

I'm trying to get the data from a Highcharts chart using Selenium. My issue is that the setExtremes function does not work with .options.data. How can I read data after using setExtremes using purely Python-based methods?

My code:

capabilities = webdriver.DesiredCapabilities().FIREFOX capabilities["marionette"] = True driver = webdriver.Firefox(capabilities=capabilities, executable_path=gecko_binary_path) driver.get(website) time.sleep(5)  temp = driver.execute_script('return window.Highcharts.charts[0].series[0]'                              '.xAxis[0].setExtremes(Date.UTC(2017, 0, 7), Date.UTC(2017, 0, 8))'                              '.options.data'                             )  data = [item for item in temp] print(data) 
like image 770
Black Avatar asked Jan 20 '18 21:01

Black


1 Answers

I am trying to execute your code on Highcharts demo page
The problem is with xAxis[0], xAxis is not an array but a dictionary, so you must supply a string value there inside those [].

check xAxis in the docs
I am guessing you're looking for xAxis.events.setExtremes

Edit

I see now that xAxis can be an array, but you're most likely missing those events so my solution should be changed to xAxis[0].events.setExtremes

like image 56
Ivan Satsiuk Avatar answered Oct 05 '22 12:10

Ivan Satsiuk