Selenium Webdriver submit()vs click() [英] Selenium Webdriver submit() vs click()
问题描述
假设我在一个表单中有一个输入
(看起来像一个按钮并像按钮一样交互),它会生成一些数据(好吧,服务器生成基于的数据)表单参数,但对于用户,按钮执行它:))基于表单中的参数。
Let's say I have an input
in a form (looks like a button and interacts like a button) which generates some data (well, the server generates the data based on the form parameters, but for the user, the button does it :) )based on the parameters in the form.
当我使用点击( )
,整个过程挂起(它实际上冻结,没有异常或错误)。
When I use click()
, the whole process hangs (it actually freezes, no exceptions or errors).
来自Selenium网站:
From the Selenium website:
// Now submit the form. WebDriver will find the form for us from the element
element.submit();
所以WebDriver有一个 submit()
方法。在按钮上使用 click()
或 submit()
之间有什么区别吗?
So WebDriver has a submit()
method. Is there any difference, logic wise, between using a click()
on a button or submit()
?
推荐答案
submit()
函数可以让生活更轻松。您可以在表单标记内的任何元素上使用它来提交该表单。
The submit()
function is there to make life easier. You can use it on any element inside of form tags to submit that form.
您还可以搜索提交按钮并使用 click()
。
You can also search for the submit button and use click()
.
所以唯一的区别是 click()
必须在提交按钮和 submit()
可以在任何表单元素上完成。
So the only difference is click()
has to be done on the submit button and submit()
can be done on any form element.
这取决于你。
http://docs.seleniumhq.org/docs/03_webdriver。 jsp#user-input-filling-in-forms
这篇关于Selenium Webdriver submit()vs click()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!