hoverOverPointOfGraphAtXAxisLabel for linecharts always give same value
vishalshivnath opened this issue · 9 comments
I am trying to read the tool tip value of line chart from http://www.highcharts.com/demo/line-basic. For that i have carried out following steps
1.Created object of LineChart and called function hoverOverPointOfGraphAtXAxisLabel chartObject.hoverOverPointOfGraphAtXAxisLabel("Mar");
2.These getToolTipLine function always give same value. System.out.println(chartObject.getToolTipLine(1));
System.out.println(chartObject.getToolTipLine(2));
System.out.println(chartObject.getToolTipLine(3));
System.out.println(chartObject.getToolTipLine(4));
3.Irrespective of label values given to function hoverOverPointOfGraphAtXAxisLabel , it always give the same results:-
4.Jun
London
:
15.2°C
Can you show me your code?
This is how my code look like :-
public void validateLineChart() throws InterruptedException {
driver.get("http://www.highcharts.com/demo/line-basic");
WebElement highChartSVGElement = driver.findElement(By.id("highcharts-0"));
LineChart chartObject = new LineChart(driver, highChartSVGElement);
assertThat(chartObject.isChartDisplayed(), is(equalTo(true)));
//Verify X and Y axis labels
String[] EXPECTED_X_AXIS_LABELS = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
String[] EXPECTED_Y_AXIS_LABELS = {"-5", "0", "5", "10", "15", "20", "25", "30"};
assertThat(chartObject.getXAxisLabelsAsArray(), is(equalTo(EXPECTED_X_AXIS_LABELS)));
assertThat(chartObject.getYAxisLabelsAsArray(), is(equalTo(EXPECTED_Y_AXIS_LABELS)));
System.out.println(chartObject.getXAxisLabelsText());
//Tool Tip Verification
chartObject.hoverOverPointOfGraphAtXAxisLabel("Mar");
System.out.println(chartObject.isTooltipDisplayed());
System.out.println(chartObject.getToolTipLine(1));
System.out.println(chartObject.getToolTipLine(2));
System.out.println(chartObject.getToolTipLine(3));
System.out.println(chartObject.getToolTipLine(4));
}
@Ardesco Did you get a chance to look at the scripts above.
Not yet, I'm a bit snowed under at the moment, I'll update as soon as I do.
Ok it looks like the SVG mark-up has changed since I originally wrote the code in powder monkey. I quickly threw this together to find the axis labels and it seems to work:
WebDriver driver = getDriver();
driver.get("http://www.highcharts.com/demo/line-basic");
WebElement highChartSVGElement = driver.findElement(By.id("highcharts-0"));
LineChart chartObject = new LineChart(driver, highChartSVGElement);
assertThat(chartObject.isChartDisplayed(), is(equalTo(true)));
//Verify X and Y axis labels
Object[] EXPECTED_X_AXIS_LABELS = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
Object[] EXPECTED_Y_AXIS_LABELS = {"-5", "0", "5", "10", "15", "20", "25", "30"};
List<String> xlabels = new ArrayList<String>();
List<WebElement> xAxisLabels = driver.findElements(By.cssSelector(".highcharts-xaxis-labels > text"));
for (WebElement xAxisLabel : xAxisLabels) {
xlabels.add(xAxisLabel.getText());
}
List<String> ylabels = new ArrayList<String>();
List<WebElement> yAxisLabels = driver.findElements(By.cssSelector(".highcharts-yaxis-labels > text"));
for (WebElement yAxisLabel : yAxisLabels) {
ylabels.add(yAxisLabel.getText());
}
assertThat(xlabels.toArray(), is(equalTo(EXPECTED_X_AXIS_LABELS)));
assertThat(ylabels.toArray(), is(equalTo(EXPECTED_Y_AXIS_LABELS)));
I would suggest using the HighCharts code as a guide rather than an out of the box thing that works, the different options available make the markup significantly different depending on how you make the graph look. I'm sure there are rules to follow but it would take quite a bit of time going through and understanding the high charts code.
sorry for confusion. I am getting label values but the area i am facing problem is reading tool tip value or moving mouse cursor from one point to another point along the line
@Ardesco Mainly we have having issues in reading all tool tips . Every time we are getting same value as mentioned in comment 1
@vishalshivnath, did you fix the issue? I am having the same problem.
Unfortunately you are looking at 5 year old code, I expect highchairs to have completely changed since I originally wrote this.