Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (29.3k points)

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()?

1 Answer

0 votes
by (50.2k points)

submit()

Submits this element to the web server. If this current element is a form, or an element within a form then this will be submitted to the web server. If this causes the current page to change, then this method will block until the new page is loaded. StaleElementReferenceException is thrown when the target element is no longer valid in the document DOM.

click()

Click this element. If the click causes a new page to load, the method will attempt to block until the page has loaded. After calling the method, you should discard all references to this element unless you know that the element and the page will still be present. Otherwise, any further operations performed on this element will have undefined behavior. ElementNotVisibleException is thrown when the target element is not visible. StaleElementReferenceException is thrown when the target element is no longer valid in the document DOM(document object model).

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

If you are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, check out Intellipaat’s Selenium certification!

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...