gpt4 book ai didi

Java/Selenium WebDriver - 单击带有 Selenium 的 JQuery 对话框按钮

转载 作者:行者123 更新时间:2023-11-29 03:33:53 25 4
gpt4 key购买 nike

我目前正在尝试使用 Selenium WebDriver 测试对话框,但“创建员工”按钮没有 ID 也没有名称。这就是代码的样子。

<div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix">
<div class="ui-dialog-buttonset">

<button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false">
<span class="ui-button-text">Create Employee</span>
</button>

<button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false">
<span class="ui-button-text">Cancel</span>
</button>

</div>

<button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false">
<span class="ui-button-text">Create Employee</span>
</button>

<button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false">
<span class="ui-button-text">Cancel</span>
</button>

</div>

谁能给我提供点击对话框中按钮的java代码?谢谢

最佳答案

尝试下面的代码。

 driver.findelement(By.xpath("//button[@type='button']/span[text()='Create Employee']")).click();

关于Java/Selenium WebDriver - 单击带有 Selenium 的 JQuery 对话框按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16537028/

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