Selenium WebDriver and Highchart testing

2019-04-02 11:01发布

I know this question has been asked before on S.O. and other websites but I haven't found a definite answer -- most of them say its not easily done but I wanted to make sure that was the final verdict.

Here's my situation:

I'm testing a website that is using Highcharts (http://www.highcharts.com) using Selenium WebDriver (Java).

I basically want to grab the information that is displayed in a small tooltip pop-up that appears when you hover your mouse over each datapoint on the Highchart's line graph.

Looking at the web page's HTML code, I noticed there is <g class="highcharts-tooltip".... I also noticed that, as you move your mouse, the (X,Y) values in ...transform="translate(X,Y)"> change, which then changes the information displayed in the tool tip.

Knowing this, my approach would be to somehow grab all the (X,Y) values and plug them into the transform fields and grab the tooltip data. But I don't know how to programmatically grab all the (X,Y) values through Selenium.

Has anyone tackles this issue in the past or has a better way to grab the necessary information?

2条回答
再贱就再见
2楼-- · 2019-04-02 11:28

I started creating a library to work with HighCharts, what I currently have is available here:

https://github.com/Ardesco/Powder-Monkey/tree/master/src/main/java/com/lazerycode/selenium/graphs

It's quite hard to provide a generic library that deals with HighCharts as the customisation options on the individual charts can modify the SVG markup quite a bit. Hopefully the above will help to a degree.

As I do more it will be updated.

查看更多
Explosion°爆炸
3楼-- · 2019-04-02 11:32

The Line Charts have to have a background to work. If the chart is created with .setBackgroundColour(null), then the "rect" is not added to the html.

I was able to to add the background colour back in set to the body background colour. However I'll try and figure out a way of doing it without the "rect".

查看更多
登录 后发表回答