Selenium找到提交按钮 [英] Selenium locate submit button

查看:518
本文介绍了Selenium找到提交按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Python中的selenium脚本,在这个阶段我试图找到一个提交按钮。

I am working on a selenium script in Python, where I am on this stage trying to locate a submit button.

<div class="submit-buttons">
<button class="submit" type="submit">Filter</button>
</div>

我已经尝试过了,但这并没有奏效。 ('Filter')。click()
browser.find_element_by_link_text('Filter')解决方案:

I've tried and this has not worked.
So I am out of solutions:

browser.find_element_by_partial_link_text('Filter').click()
browser.find_element_by_link_text('Filter').click()
browser.find_element_by_class_name('submit').click()


推荐答案

尝试xpath解决方案:

Try xpath solution:

driver.find_element_by_xpath('//div[@class="submit-buttons"]/button[@class="submit"]')

如果是仍然无法识别,元素可能位于一个框架内,而您必须在找到该元素之前切换到该框架。

If it is still not identifying, the element might be inside a frame, and you have to switch to that frame before finding the element.

这篇关于Selenium找到提交按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆