【发布时间】:2023-04-01 00:30:01
【问题描述】:
我尝试使用 xpath、类名和 css 定位器单击此按钮。我什至等待了一段时间,以便它可以先正确加载,但没有任何效果。仍然无法点击按钮,请帮助。
<div class="relative create-disbursement-dropdown" size="small">
<button data-v-a7f43302="" type="button" variant="solid" color="green" size="small" lefticon="" righticon="" options="[object Object],[object Object]" class="
relative
box-border
transition-all
duration-200
font-sans font-semibold
rounded-semi
py-2
disabled:pointer-events-none
disabled:cursor-default
focus:outline-none
btn-small btn-solid btn-green"><div data-v-a7f43302="" class="flex items-center justify-center space-x-2">
<div data-v-a7f43302="" class="flex items-center justify-center space-x-2"><!---->
<span data-v-a7f43302=""> Create Disbursement </span>
</div>
</button>
</div>
[这是按钮的样子] :https://i.stack.imgur.com/cml4u.png
我的代码是这样的:
WebElement createDisburseButton = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"disbursement-root\"]/div/div[1]/div/button")));
createDisburseButton.click();
错误:
Expected condition failed: waiting for element to be clickable: By.xpath: //*[@id="disbursement-root"]/div/div[1]/div/button (tried for 10 second(s) with 500 milliseconds interval)
【问题讨论】:
-
为了能够提供帮助,请提供失败的执行代码(java 类)、更扩展的 DOM 以及与问题相关的大量堆栈跟踪。根据目前提供的信息,问题可能是什么。还提供指向网页的链接,如果该链接是内部的,请提供您希望单击的内容的屏幕截图,同时通过 F12 选项显示该按钮与 DOM 的检查
-
你遇到了什么错误?
-
我编辑了描述,感谢@djmonki 的帮助
-
我编辑了描述,感谢@cruisepandey 的帮助
-
@Clara:请看下面我的回答。
标签: python java selenium xpath automation