Closed willkim1 closed 3 years ago
Thank you for this suggestion. Being able to override the entire body is something that is still missing from Selenium Wire and could prove useful.
With regard to param_overrides
not detecting the type properly, are you sure that the content type being sent with the POST request is definitely application/x-www-form-urlencoded
? It may be worth explicitly setting the content type to application/x-www-form-urlencoded
for the request in question just to be sure, using header_overrides
:
driver.header_overrides = [
('.*/path/of/post/request.*', {'Content-Type': 'application/x-www-form-urlencoded'})
]
driver.param_overrides = [
('.*/path/of/post/request.*', {formKey1: 'formValue1', formKey2: 'formValue2'})
]
For form requests, it would be nice to modify the body like we do for headers, params, querystrings
Param_overrides is supposed to detect if application/x-www-form-urlencoded to modify the body, but it was not detecting the type properly. Having body_overrides could help debug the issue.
driver.body_overrides = { formKey1: 'formValue1', formKey2: 'formValue2' }
This brings us closer to feature-parity with other libraries like python requests.
This feature has been added in 2.1.2.
The body_overrides
attribute exists in 2.1.2 but the feature is undocumented currently. Documentation to be added soon.
body_overrides
has been deprecated and superseded with request interceptors in version 3.0.0 of Selenium Wire. You can now use a request interceptor to modify the body of the request on the fly.
For form requests, it would be nice to modify the body like we do for headers, params, querystrings
Param_overrides is supposed to detect if application/x-www-form-urlencoded to modify the body, but it was not detecting the type properly. Having body_overrides could help debug the issue.
This brings us closer to feature-parity with other libraries like python requests.