0 votes
1 view
in Devops and Agile by (28.1k 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 (48k 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

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...