Selenium Webdriver submit() 与 click() [英] Selenium Webdriver submit() vs click()
问题描述
假设我在一个表单中有一个 input
(看起来像一个按钮并像一个按钮一样交互)它生成一些数据(好吧,服务器根据表单参数生成数据,但是对于用户,按钮执行 :) ) 基于表单中的参数.
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.
当我使用 click()
时,整个过程挂起(它实际上冻结了,没有异常或错误).
When I use click()
, the whole process hangs (it actually freezes, no exceptions or errors).
来自硒网站:
// 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() 与 click()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!