Repository navigation
Description
Meta
OS: any
Selenium Version: 3.3.1
Browser: Firefox 52.0
Geckodriver: 0.15.0
Expected Behavior
Form is submitted using /wd/hub/session/XXX/element/X/submit call.
Actual Behavior
Error is thrown on some forms.
Steps to reproduce
- Using Selenium and latest Firefox, go to http://www.seleniumhq.org/
- Fill the search form and submit:
$input = $driver->findElement(
WebDriverBy::id('q')
);
$input->sendKeys('foo')->submit();- The form is submitted, however, Selenium throws an exception (see below).
I guess there is some bug in the javascript shim for the form submit (#2854 and https://github.com/SeleniumHQ/selenium/blob/master/java/client/src/org/openqa/selenium/remote/http/W3CHttpCommandCodec.java#L284-L295).
If a form control (such as a submit button) has a name or id of submit it will mask the form's submit method.
The example was done with PHP language bindings, however, the commands are translated by the Selenium server.
Originally reported as php-webdriver/php-webdriver#402.
The same code is working with Firefox 47 & Chrome driver.
Selenium exception:
10:51:02.085 DEBUG - Handling: POST /session/dae23264-8fe0-4ae4-a170-215fb447e4f2/element/1/submit
10:51:02.085 INFO - Executing: [submit: 1 [[FirefoxDriver: firefox on LINUX (26ee35ed-fced-44a3-a0b9-141997f8c8b7)] -> id: q]])
10:51:02.086 DEBUG - Executing: submitElement [26ee35ed-fced-44a3-a0b9-141997f8c8b7, submitElement {id=eb9665a9-d780-4a3e-a4f8-c5cbcb4c42b2}]
10:51:02.087 DEBUG - CookieSpec selected: default
10:51:02.087 DEBUG - Auth cache not set in the context
10:51:02.087 DEBUG - Connection request: [route: {}->http://localhost:11171][total kept alive: 0; route allocated: 0 of 2000; total allocated: 0 of 2000]
10:51:02.087 DEBUG - Connection leased: [id: 11][route: {}->http://localhost:11171][total kept alive: 0; route allocated: 1 of 2000; total allocated: 1 of 2000]
10:51:02.087 DEBUG - Opening connection {}->http://localhost:11171
10:51:02.087 DEBUG - Connecting to localhost/127.0.0.1:11171
10:51:02.088 DEBUG - Connection established 127.0.0.1:58086<->127.0.0.1:11171
10:51:02.088 DEBUG - http-outgoing-11: set socket timeout to 10800000
10:51:02.088 DEBUG - Executing request POST /session/26ee35ed-fced-44a3-a0b9-141997f8c8b7/execute/sync HTTP/1.1
10:51:02.088 DEBUG - Target auth state: UNCHALLENGED
10:51:02.088 DEBUG - Proxy auth state: UNCHALLENGED
10:51:02.088 DEBUG - http-outgoing-11 >> POST /session/26ee35ed-fced-44a3-a0b9-141997f8c8b7/execute/sync HTTP/1.1
10:51:02.088 DEBUG - http-outgoing-11 >> Content-Type: application/json; charset=utf-8
10:51:02.088 DEBUG - http-outgoing-11 >> Content-Length: 493
10:51:02.088 DEBUG - http-outgoing-11 >> Host: localhost:11171
10:51:02.088 DEBUG - http-outgoing-11 >> Connection: Keep-Alive
10:51:02.088 DEBUG - http-outgoing-11 >> User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_121)
10:51:02.088 DEBUG - http-outgoing-11 >> Accept-Encoding: gzip,deflate
10:51:02.088 DEBUG - http-outgoing-11 >> "POST /session/26ee35ed-fced-44a3-a0b9-141997f8c8b7/execute/sync HTTP/1.1[\r][\n]"
10:51:02.088 DEBUG - http-outgoing-11 >> "Content-Type: application/json; charset=utf-8[\r][\n]"
10:51:02.088 DEBUG - http-outgoing-11 >> "Content-Length: 493[\r][\n]"
10:51:02.089 DEBUG - http-outgoing-11 >> "Host: localhost:11171[\r][\n]"
10:51:02.089 DEBUG - http-outgoing-11 >> "Connection: Keep-Alive[\r][\n]"
10:51:02.089 DEBUG - http-outgoing-11 >> "User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_121)[\r][\n]"
10:51:02.089 DEBUG - http-outgoing-11 >> "Accept-Encoding: gzip,deflate[\r][\n]"
10:51:02.089 DEBUG - http-outgoing-11 >> "[\r][\n]"
10:51:02.089 DEBUG - http-outgoing-11 >> "{"script":"var form = arguments[0];\nwhile (form.nodeName != \"FORM\" && form.parentNode) {\n form = form.parentNode;\n}\nif (!form) { throw Error('Unable to find containing form element'); }\nif (!form.ownerDocument) { throw Error('Unable to find owning document'); }\nvar e = form.ownerDocument.createEvent('Event');\ne.initEvent('submit', true, true);\nif (form.dispatchEvent(e)) { form.submit() }\n","args":[{"element-6066-11e4-a52e-4f735466cecf":"eb9665a9-d780-4a3e-a4f8-c5cbcb4c42b2"}]}"
10:51:02.136 DEBUG - http-outgoing-11 << "HTTP/1.1 500 Internal Server Error[\r][\n]"
10:51:02.136 DEBUG - http-outgoing-11 << "Connection: close[\r][\n]"
10:51:02.136 DEBUG - http-outgoing-11 << "Content-Type: application/json[\r][\n]"
10:51:02.137 DEBUG - http-outgoing-11 << "Content-Length: 81[\r][\n]"
10:51:02.137 DEBUG - http-outgoing-11 << "Date: Mon, 23 Jan 2017 09:51:02 GMT[\r][\n]"
10:51:02.137 DEBUG - http-outgoing-11 << "[\r][\n]"
10:51:02.137 DEBUG - http-outgoing-11 << "{"error":"javascript error","message":"TypeError: form.submit is not a function"}"
10:51:02.137 DEBUG - http-outgoing-11 << HTTP/1.1 500 Internal Server Error
10:51:02.137 DEBUG - http-outgoing-11 << Connection: close
10:51:02.137 DEBUG - http-outgoing-11 << Content-Type: application/json
10:51:02.137 DEBUG - http-outgoing-11 << Content-Length: 81
10:51:02.137 DEBUG - http-outgoing-11 << Date: Mon, 23 Jan 2017 09:51:02 GMT
10:51:02.138 DEBUG - http-outgoing-11: Close connection
10:51:02.138 DEBUG - Connection discarded
10:51:02.138 DEBUG - Connection released: [id: 11][route: {}->http://localhost:11171][total kept alive: 0; route allocated: 0 of 2000; total allocated: 0 of 2000]
10:51:02.139 DEBUG - Decoding response. Response code was: 500 and content: {"error":"javascript error","message":"TypeError: form.submit is not a function"}
10:51:02.139 DEBUG - Processing an error
Activity
mirao commentedon Jan 23, 2017
I did one some more testing on my own page with
id="submit"and then withid="submitb", both with the next$input->sendKeys('php')->submit();. The 1st variant fails in Firefox, the latter variant passes in Firefox. Both variants work well in Chrome.[-]Error submitting form with Selenium 3.0.1 & Geckodriver[/-][+]Cannot submit form with id="submit" (Selenium 3 & Geckodriver)[/+]Adding tests for #3398
[java] Fix submitting form containing input with name or id "submit" (#…
barancev commentedon Sep 10, 2017
Fixed by 865c140
[java] Fix submitting form containing input with name or id "submit" (S…
Remove workaround for selenium bug SeleniumHQ/selenium#3398
hellfireSteve commentedon Jul 18, 2018
OK. Can't see it above. How do I solve "Error: Unable to find owning document"? in my test case?
Remove workaround for selenium bug SeleniumHQ/selenium#3398