Skip to content

Commit

Permalink
Dispatch form "submit" event on window to prevent a form double submi…
Browse files Browse the repository at this point in the history
…ssion (#6361)
  • Loading branch information
whimboo authored and davehunt committed Sep 6, 2018
1 parent 9fd4cf7 commit 58e75ca
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions py/selenium/webdriver/remote/webelement.py
Expand Up @@ -84,9 +84,10 @@ def submit(self):
if self._w3c:
form = self.find_element(By.XPATH, "./ancestor-or-self::form")
self._parent.execute_script(
"var e = arguments[0].ownerDocument.createEvent('Event');"
"var win = arguments[0].ownerDocument;"
"var e = win.createEvent('Event');"
"e.initEvent('submit', true, true);"
"if (arguments[0].dispatchEvent(e)) { arguments[0].submit() }", form)
"if (win.dispatchEvent(e)) { arguments[0].submit() }", form)
else:
self._execute(Command.SUBMIT_ELEMENT)

Expand Down

0 comments on commit 58e75ca

Please sign in to comment.