gpt4 book ai didi

java - 我无法通过我的代码单击按钮元素,有人可以在这里提供帮助吗

转载 作者:行者123 更新时间:2023-12-02 04:38:53 24 4
gpt4 key购买 nike

我希望能够使用 Java 通过我的 selenium 脚本单击按钮。

我尝试通过类以多种方式执行此操作,并在 xpath 中建立索引:

1) driver.findElement(By.xpath("contains(@class,'btn btn-alt btn-small tooltip-element') and contains(@tabindex,'0')")).click();

2) driver.findElement(By.xpath("//*button[@tabindex=0]")).click();

我的html路径如下:
<a href="#" class="btn btn-alt btn-small tooltip-element" tabindex="0" role="button" data-placement="bottom" aria-label="Help" ng-click="ecdapp.uploadBlueprintModalPopup()" aria-expanded="true" aria-describedby="tooltiptextBtn"> Create <span class="arrow"></span>
</a>

最佳答案

试试这个代码:

driver.findElement(By.linkText('Create')).click();

关于java - 我无法通过我的代码单击按钮元素,有人可以在这里提供帮助吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56530407/

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