Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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).

From the Selenium website:

// Now submit the form. WebDriver will find the form for us from the element element.submit(); 

So WebDriver has a submit() method. Is there any difference, logic wise, between using a click() on a button or submit() ?

like image 931
CosminO Avatar asked Jul 08 '13 15:07

CosminO


People also ask

What is click () method in Selenium?

How to use the Selenium Click command. To put it in simple words, the click command emulates a click operation for a link, button, checkbox or radio button. In Selenium Webdriver, execute click after finding an element. In SeleniumIDE, the recorder will do the identifying, and the command is simply click.

What is the use of Submit method in Selenium?

The submit() function is there to make life easier. You can use it on any element inside of form tags to submit that form. You can also search for the submit button and use click() . So the only difference is click() has to be done on the submit button and submit() can be done on any form element.

Where is the submit button in Selenium?

You could try to find the element with an XPath expression or a CSS selector like input[type="button"], and then just click the element.

What is contextClick () used for?

Move to Element: contextClick() method first performs mouseMove to the middle of the element location. This function performs the right click at the middle of the web element.


1 Answers

The submit() function is there to make life easier. You can use it on any element inside of form tags to submit that form.

You can also search for the submit button and use click().

So the only difference is click() has to be done on the submit button and submit() can be done on any form element.

It's up to you.

http://docs.seleniumhq.org/docs/03_webdriver.jsp#user-input-filling-in-forms

like image 108
Dan2.0 Avatar answered Sep 20 '22 00:09

Dan2.0