Skip to content

Commit

Permalink
[rb] Dispatch form "submit" event on window to prevent a form double …
Browse files Browse the repository at this point in the history
…submission (#6373)

This fixes the Ruby bindings for issue #6361.
  • Loading branch information
whimboo authored and lmtierney committed Sep 6, 2018
1 parent bbd0774 commit 946b7a2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions rb/lib/selenium/webdriver/remote/w3c/bridge.rb
Expand Up @@ -388,9 +388,10 @@ def clear_element(element)

def submit_element(element)
form = find_element_by('xpath', "./ancestor-or-self::form", element)
execute_script("var e = arguments[0].ownerDocument.createEvent('Event');" \
execute_script("var win = arguments[0].ownerDocument;" \
"var e = win.createEvent('Event');" \
"e.initEvent('submit', true, true);" \
'if (arguments[0].dispatchEvent(e)) { arguments[0].submit() }', form.as_json)
'if (win.dispatchEvent(e)) { arguments[0].submit() }', form.as_json)
end

def drag_element(element, right_by, down_by)
Expand Down

0 comments on commit 946b7a2

Please sign in to comment.