我正在尝试捕获基于ElasticSearch的网站上不同图形(饼图/直方图/线条)上显示的数据。它提供了有关从数据库中轮询的数据的各种信息。
我面临的问题是捕获mouseOver发生时出现的数据。我试图通过xpath甚至id捕获数据。不幸的是,我没有取得任何成功。
在饼图部分中呈现的页面的html如下所示:
<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>
我尝试过的选项如下:
选项1: assertEquals(“User”,driver.findElement(By.xpath(“// div [2] / div [2] / div / div / div [2] / div / div [2] / div [1] / div / DIV / kibana面板/ DIV / DIV [2] / DIV [3] /跨度[1] / DIV“))的getText());
选项2:
driver.findElement(By.xpath(“// DIV [2] / DIV [2] / DIV / DIV / DIV [1] / DIV / DIV [2] / DIV [2] / DIV / DIV / kibana面板/ 。DIV / DIV [2] / DIV [2] /帆布[2]“))点击();
driver.findElement(By.xpath(“// DIV [2] / DIV [2] / DIV / DIV / DIV [1] / DIV / DIV [2] / DIV [2] / DIV / DIV / kibana面板/ DIV / DIV [2] / DIV [2] / DIV / DIV [1] / DIV [1]“))的getText();
选项3: String someVal = driver.findElement(By.xpath(“// * [@ id ='pieLabel0']”))。getText();
你能告诉我我可能做错了什么以及如何解决这个问题吗?
答案 0 :(得分:2)
尝试使用与该表相关的HTML路径。如果要分析图中的值,只需将其指向xpath,然后检索并存储下面提到的值,
String chartValue = toolTip.getText();
System.out.println(chartValue);
如果你仍然怀疑,请看看dis网站 http://roadtoautomation.blogspot.in/2014/03/road-to-reading-svg-graph-values-in.html