Powder-Monkey icon indicating copy to clipboard operation
Powder-Monkey copied to clipboard

hoverOverPointOfGraphAtXAxisLabel for linecharts always give same value

Open vishalshivnath opened this issue 11 years ago • 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

vishalshivnath avatar Mar 14 '14 09:03 vishalshivnath

Can you show me your code?

Ardesco avatar Mar 14 '14 09:03 Ardesco

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));



  }

vishalshivnath avatar Mar 14 '14 09:03 vishalshivnath

@Ardesco Did you get a chance to look at the scripts above.

vishalshivnath avatar Mar 18 '14 16:03 vishalshivnath

Not yet, I'm a bit snowed under at the moment, I'll update as soon as I do.

Ardesco avatar Mar 19 '14 08:03 Ardesco

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.

Ardesco avatar Mar 19 '14 19:03 Ardesco

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

vishalshivnath avatar Mar 20 '14 11:03 vishalshivnath

@Ardesco Mainly we have having issues in reading all tool tips . Every time we are getting same value as mentioned in comment 1

vishalshivnath avatar Mar 27 '14 06:03 vishalshivnath

@vishalshivnath, did you fix the issue? I am having the same problem.

jessicafei026x avatar Sep 21 '17 22:09 jessicafei026x

Unfortunately you are looking at 5 year old code, I expect highchairs to have completely changed since I originally wrote this.

Ardesco avatar Sep 22 '17 01:09 Ardesco