gpt4 book ai didi

javascript - Selenium C# : Locate element on chart

转载 作者:太空宇宙 更新时间:2023-11-03 15:40:01 24 4
gpt4 key购买 nike

我想识别此图表上的刺激频率圆圈,以便我可以单击并拖动它们。 enter image description here

<svg class="svg-graph-content graphEventHandler ng-valid" ng-model="hearingGraph" viewBox="0 0 470 355" preserveAspectRatio="none">
<path class="" ng-show="audiogram.leftEnabled" ep-d="M42 148.39999389648438 L126 148.71843558091385 L210 147.23333740234375 L294 147.86266635014462 L378 147.86266635014462 L462 147.86266635014462" fill-opacity="0" stroke-width="2" stroke="rgb(0,0,255)" d="M42 148.39999389648438 L126 148.71843558091385 L210 147.23333740234375 L294 147.86266635014462 L378 147.86266635014462 L462 147.86266635014462" style="">
<circle class="" ng-touch="manualGraph($event, c, 'left')" ng-mousedown="manualGraph($event, c, 'left')" ng-show="audiogram.leftEnabled && manual" ng-repeat="c in audiogram.tonePoints | filter: {'resultSet': 'left'} | orderBy : 'stimulusFrequency'" fill="black" ep-r="8" ep-cy="148.39999389648438" ep-cx="42" cy="148.39999389648438" cx="42" r="8">

我想与之交互的图表部分是“圆类”,使用 Firebug ,我发现其中一个圆的 XPath 如下,但我得到了“没有这样的元素”异常。

.//*[@id='layout-wrapper']/ui-view/ui-view/div/ep-annotation-widget/div/div/div/div[1]/div[4]/div[1]/div[2]/svg/circle[1]

我通过使用取得了一些进步:

var circles = Driver.Instance.FindElements(By.TagName("circle")); 

但是这给出了 27 个结果,而应该只有 12 个结果,所以我会继续努力。

最佳答案

这是我想出来的。如果您有更有效的方法,请告诉我。

    public static void MoveNode(string ear, int frequency)
{
int circleRef = 0;
switch (frequency)
{
case 250:
if (ear == "right")
{
circleRef = 12;
}
else if (ear == "left")
{
circleRef = 0;
}
break;
case 500:
if (ear == "right")
{
circleRef = 13;
}
else if (ear == "left")
{
circleRef = 1;
}
break;
}
var circles = Driver.Instance.FindElements(By.TagName("circle"));
circles[circleRef].Click();
//add logic for dragging and releasing
}

关于javascript - Selenium C# : Locate element on chart,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30584885/

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