continue_button = browser.find_element_by_xpath("//input[@type='button' and @class='primary button']")
continue_button.click();
由于某种原因,这不起作用。这就是我所知道的点击按钮: 它在一个div AND
<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>
答案 0 :(得分:3)
您尝试点击的元素类型为<button>
。
首先,您需要将//input
更改为//button
。
此外,您不必同时使用class
属性和type
属性,除非这是唯一标识该元素的唯一组合。否则,您可以只使用唯一标识元素的属性(class
属性或type
属性)。