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 (SeleniumHQ#6373)

This fixes the Ruby bindings for issue SeleniumHQ#6361.
  • Loading branch information
whimboo authored and Grigory Mischenko committed Sep 20, 2018
1 parent 375343e commit 1ad1f0c
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 1ad1f0c

Please sign in to comment.