As per the current API Docs of selenium.webdriver.remote.webelement the method submit() is defined as follows :
submit()
Submits a form.
As per the source code, submit() looks for the ancestor-or-self as form, creates an event and dispatches. In case of failure Command.SUBMIT_ELEMENT is executed.
Source Code :
def submit(self):
"""Submits a form."""
if self._w3c:
form = self.find_element(By.XPATH, "./ancestor-or-self::form")
self._parent.execute_script(
"var e = arguments[0].ownerDocument.createEvent('Event');"
"e.initEvent('submit', true, true);"
"if (arguments[0].dispatchEvent(e)) { arguments[0].submit() }", form)
else:
self._execute(Command.SUBMIT_ELEMENT)
So, it's apparent that submit() is the full proof approach to follow though in some cases submit may also cater to your needs. But following the Best Practices submit must be avoided.
element.submit?self.webdriver.find_element_by_xpath('//*[@id="search"]/input').submitreturn a result" ? What result? Everything might "return a result"... Can you put more meaning into your question?