gpt4 book ai didi

java - 无法让 selenium 使用 xpath 为我选择按钮。我缺少什么?

转载 作者:行者123 更新时间:2023-12-01 23:11:16 29 4
gpt4 key购买 nike

continue_button = browser.find_element_by_xpath("//input[@type='button' and @class='primary button']")
continue_button.click();

由于某种原因,这不起作用。这是我对我点击的按钮的了解:它在一个 div 中并且

<button class="primary button" type="button"></button>

这就是我所要做的。帮助? browser.find_element_by_id 对于同一页面上的其他项目非常有用,因此我的驱动程序和一切都正常工作。

它加载页面,在我设置的字段中输入文本,我希望它单击“继续”按钮,然后它就停止并结束。

原始html:

<div class="GLHWMP-BMTC">

<span class="inlineBlock GLHWMP-BDUC">
<button class="primary button" type="button"></button>
<span class="GLHWMP-BPTC GLHWMP-BEUC"></span>
<span class="GLHWMP-BPTC GLHWMP-BLTC"></span>
</span>

最佳答案

您尝试单击的元素的类型是 <button> .

因此,首先,您需要更改 //input//button .

此外,您不必同时使用 class属性和 type属性,除非这是唯一标识该元素的唯一组合。否则,您可以简单地使用唯一标识该元素的属性(class 属性或 type 属性)。

关于java - 无法让 selenium 使用 xpath 为我选择按钮。我缺少什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21942680/

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