Skip to content

Commit

Permalink
Add support for submit() with W3C compliant endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
AutomatedTester committed Jan 27, 2016
1 parent 84f0f34 commit 19d6bc9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion py/selenium/webdriver/remote/webelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ def click(self):

def submit(self):
"""Submits a form."""
self._execute(Command.SUBMIT_ELEMENT)
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)

def clear(self):
"""Clears the text if it's a text entry element."""
Expand Down

0 comments on commit 19d6bc9

Please sign in to comment.