gpt4 book ai didi

java - 如何在自动化过程中点击 Highchart 元素

转载 作者:行者123 更新时间:2023-11-30 07:45:50 25 4
gpt4 key购买 nike

有什么方法可以获取 SmartGWT hightchart 图中元素的定位器(sclocator 或 xpath 等)?我需要在图表的系列图例(出现在图表右侧的系列)上自动执行点击操作。

这些是我试图为这个图的元素识别一个有效定位器的东西:

  • 使用 Relative Xpath Helper 插件。单击 highchart 图的任何元素后,我收到消息:“未找到唯一标识符”。
  • 使用 Selenium IDE 为 smartgwt 设置“user-extensions.js”和“user-extensions-ide.js”selenium 库。在尝试识别这些系列的定位器或图中任何其他元素后,我收到消息:“LOCATOR_DETECTION_FAILED”。
  • 使用Selenium Page Object Generator插件。生成java文件后,java文件中没有生成图像相关的信息。

任何帮助将不胜感激。

提前致谢!

Graph Highchart

<g class="highcharts-legend" zIndex="7" transform="translate(-32,110)">
<g zIndex="1" clip-path="url(#highcharts-2)">
<g transform="translate(0,1)">
<g class="highcharts-legend-item" zIndex="1" transform="translate(8,3)">
<path fill="none" d="M 0 11 L 16 11" stroke-dasharray="none" stroke="#C00000" stroke-width="2"></path>
<path fill="#C00000" d="M 8 9 C 10.664 9 10.664 13 8 13 C 5.336 13 5.336 9 8 9 Z"></path>
<text x="21" y="15" style="font-family:&quot;Lucida Grande&quot;, &quot;Lucida Sans Unicode&quot;, Verdana, Arial, Helvetica, sans-serif;font-size:12px;cursor:pointer;color:#274b6d;fill:#274b6d;" text-anchor="start" zIndex="2">
<tspan x="21">Worst Inventory On Site</tspan>
</text>
</g>
<g class="highcharts-legend-item" zIndex="1" transform="translate(8,21)">
<path fill="none" d="M 0 11 L 16 11" stroke-dasharray="none" stroke="#3A5723" stroke-width="2"></path>
<path fill="#3A5723" d="M 8 9 C 10.664 9 10.664 13 8 13 C 5.336 13 5.336 9 8 9 Z"></path>
<text x="21" y="15" style="font-family:&quot;Lucida Grande&quot;, &quot;Lucida Sans Unicode&quot;, Verdana, Arial, Helvetica, sans-serif;font-size:12px;cursor:pointer;color:#274b6d;fill:#274b6d;" text-anchor="start" zIndex="2">
<tspan x="21">Total Ins</tspan>
</text>
</g>
<g class="highcharts-legend-item" zIndex="1" transform="translate(8,39)">
<path fill="none" d="M 0 11 L 16 11" stroke-dasharray="none" stroke="#CCC" stroke-width="2"></path>
<path fill="#CCC" d="M 8 9 C 10.664 9 10.664 13 8 13 C 5.336 13 5.336 9 8 9 Z"></path>
<text x="21" y="15" style="font-family:&quot;Lucida Grande&quot;, &quot;Lucida Sans Unicode&quot;, Verdana, Arial, Helvetica, sans-serif;font-size:12px;cursor:pointer;color:#CCC;fill:#CCC;" text-anchor="start" zIndex="2">
<tspan x="21">Total Outs</tspan>
</text>
</g>
<g class="highcharts-legend-item" zIndex="1" transform="translate(8,57)">
<path fill="none" d="M 0 11 L 16 11" stroke-dasharray="2,2" stroke="#CCC" stroke-width="2"></path>
<path fill="#CCC" d="M 8 9 C 10.664 9 10.664 13 8 13 C 5.336 13 5.336 9 8 9 Z"></path>
<text x="21" y="15" style="font-family:&quot;Lucida Grande&quot;, &quot;Lucida Sans Unicode&quot;, Verdana, Arial, Helvetica, sans-serif;font-size:12px;cursor:pointer;color:#CCC;fill:#CCC;" text-anchor="start" zIndex="2">
<tspan x="21">Inventory On Site</tspan>
</text>
</g>
<g class="highcharts-legend-item" zIndex="1" transform="translate(8,75)">
<path fill="none" d="M 0 11 L 16 11" stroke-dasharray="6,2" stroke="#CCC" stroke-width="2"></path>
<path fill="#CCC" d="M 8 9 C 10.664 9 10.664 13 8 13 C 5.336 13 5.336 9 8 9 Z"></path>
<text x="21" y="15" style="font-family:&quot;Lucida Grande&quot;, &quot;Lucida Sans Unicode&quot;, Verdana, Arial, Helvetica, sans-serif;font-size:12px;cursor:pointer;color:#CCC;fill:#CCC;" text-anchor="start" zIndex="2">
<tspan x="21">Inventory On Transit</tspan>
</text>
</g>
</g>
</g>
</g>

最佳答案

感谢@dangi13 的帮助。但是我找到了一个使用不同 xpath 结构的解决方案:

sharedData.appInstance.findElement(By.xpath("//[name()='g' and @class='highcharts-legend']//[name()='text']//*[name()='tspan' and text()='Worst Inventory on Site']")).click();

关于java - 如何在自动化过程中点击 Highchart 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51268312/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com