Difference between click and submit methods in Selenium webdriver?

In this article, i will talk about difference between click and submit method. Submit is for Forms and Click is for Buttons

If you submit using any element of Form, it will automatically find button with type ‘submit’ of form and click on it.

Submit can be done on any form item and click has to be done Button with type Submit

Both click() and submit() both are used to click Button in Web page.

Selenium WebDriver has one special method to submit any form and that method name Is submit(). submit() method works same as clicking on submit button.

.click() method :
You can use .click() method to click on any button. There is no restriction for click buttons.
That means element’s type = “button” or type = “submit”, .click() method will works for both.
If button is inside <form> tag or button is outside <form> tag, the click() method will work.

.submit() method :
we can use .submit() method for only submit form after click on button.
That means element’s type = “submit” and button should be inside <form> tag, then only submit() will work.
If element’s type = “button” means submit() will not work.
If button outside of the <form> tag means submit() will not work

For Example, Submit() will work if submit button should be inside <form> tag and element type=”submit” as below

<input id="submitbutton" name="submitbutton" type="submit" value="Next step" class=

"g-button g-button-submit">

But click() method will work for allĀ  buttons in webpage with out any restrictions.

Hope this helps !!!

Leave Comment

Your email address will not be published. Required fields are marked *

Looking for learning Framework Development from Scratch? Lookout for Detailed Framework Development videos on YouTube here -


Get the Framework code at Github Repo: https://github.com/prakashnarkhede?tab=repositories