Reputation: 41
I am trying to capture the data that is displayed on different graphs (pie/histogram/line) on a website that is based on ElasticSearch. It presents various information on data polled from a database.
The problem I am facing is in capturing the data that appears when the mouseOver happens. I have tried to capture the data through the xpath and even the id. Unfortunately I have not met with any success.
The html of the page rendered as in the pie-chart part is shown below:
<div class="panel-content">
<style></style>
<div id="03D-legend" ng-show="panel.counter_pos == 'above' && (panel.chart == 'bar' || panel.chart == 'pie')"></div>
<div style="clear:both"></div>
<div class="pointer" style="position: relative; height: 350px; padding: 0px;" params="{"error":false,"span":2,"editable":true,"type":"terms","load…e":"terms","tstat":"total","valuefield":"","title":"Domain"}" terms-chart="" ng-show="panel.chart == 'pie' || panel.chart == 'bar'">
<canvas class="flot-base" style="direction: ltr; position: absolute; left: 0px; top: 0px; width: 213px; height: 350px;" width="266" height="437"></canvas>
<canvas class="flot-overlay" style="direction: ltr; position: absolute; left: 0px; top: 0px; width: 213px; height: 350px;" width="266" height="437"></canvas>
<span id="pieLabel0" class="pieLabel" style="position: absolute; top: 154px; left: 164.5px;">
<div style="font-size:8pt;text-align:center;padding:2px;color:white;" ng-click="build_search(panel.field,'User') ">
User
<br></br>
50%
</div>
</span>
<span id="pieLabel1" class="pieLabel" style="position: absolute; top: 152px; left: 15.5px;"></span>
</div>
<div id="03D-legend" ng-show="panel.counter_pos == 'below' && (panel.chart == 'bar' || panel.chart == 'pie')" style="display: none;"></div>
<table class="table table-striped table-condensed" ng-show="panel.chart == 'table'" ng-style="panel.style" style="display: none; font-size: 10pt;"></table>
</div>
</div>
</kibana-panel>
The options I have tried are the following:
Option1: assertEquals("User", driver.findElement(By.xpath("//div[2]/div[2]/div/div/div[2]/div/div[2]/div[1]/div/div/kibana-panel/div/div[2]/div[3]/span[1]/div")).getText());
Option2:
driver.findElement(By.xpath("//div[2]/div[2]/div/div/div[1]/div/div[2]/div[2]/div/div/kibana-panel/div/div[2]/div[2]/canvas[2]")).click();
driver.findElement(By.xpath("//div[2]/div[2]/div/div/div[1]/div/div[2]/div[2]/div/div/kibana-panel/div/div[2]/div[2]/div/div[1]/div[1]")).getText();
Option3: String someVal = driver.findElement(By.xpath("//*[@id='pieLabel0']")).getText();
Can you please advise me on what I may be doing wrong and how to approach this?
Upvotes: 0
Views: 3864
Reputation: 174
Try to find using HTML paths relevant to that table. If you want to analyze the values from graph, just point it by its xpath, and then retrieve and store the value as mentioned below,
String chartValue = toolTip.getText();
System.out.println(chartValue);
If you hav doubts still, Have a look at dis site http://roadtoautomation.blogspot.in/2014/03/road-to-reading-svg-graph-values-in.html
Upvotes: 2