You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 3, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.rst
+14-9
Original file line number
Diff line number
Diff line change
@@ -249,7 +249,7 @@ Request objects have the following attributes.
249
249
A dictionary-like object of request headers. Headers are case-insensitive and duplicates are permitted. Asking for ``request.headers['user-agent']`` will return the value of the ``User-Agent`` header. If you wish to replace a header, make sure you delete the existing header first with ``del request.headers['header-name']``, otherwise you'll create a duplicate.
250
250
251
251
``method``
252
-
The HTTP method type, e.g. ``GET`` or ``POST``.
252
+
The HTTP method type, e.g. ``GET`` or ``POST`` etc.
253
253
254
254
``params``
255
255
A dictionary of request parameters. If a parameter with the same name appears more than once in the request, it's value in the dictionary will be a list.
@@ -289,15 +289,15 @@ Response objects have the following attributes.
289
289
A dictionary-like object of response headers. Headers are case-insensitive and duplicates are permitted. Asking for ``response.headers['content-length']`` will return the value of the ``Content-Length`` header. If you wish to replace a header, make sure you delete the existing header first with ``del response.headers['header-name']``, otherwise you'll create a duplicate.
290
290
291
291
``reason``
292
-
The reason phrase, e.g. ``OK`` or ``Not Found``.
292
+
The reason phrase, e.g. ``OK`` or ``Not Found`` etc.
293
293
294
294
``status_code``
295
-
The status code of the response, e.g. ``200`` or ``404``.
295
+
The status code of the response, e.g. ``200`` or ``404`` etc.
296
296
297
297
Intercepting Requests and Responses
298
298
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
299
299
300
-
Selenium Wire allows you to modify requests and responses on the fly using interceptors. An interceptor is a function that gets invoked with the requests and responses as they pass through Selenium Wire. Within an interceptor you can modify the request and response as you see fit.
300
+
Selenium Wire allows you to modify requests and responses on the fly using interceptors. An interceptor is a function that gets invoked with requests and responses as they pass through Selenium Wire. Within an interceptor you can modify the request and response as you see fit.
301
301
302
302
You set your interceptor functions using the ``driver.request_interceptor`` and ``driver.response_interceptor`` attributes before you start using the driver. A request interceptor should accept a single argument for the request. A response interceptor should accept two arguments, one for the originating request and one for the response.
303
303
@@ -310,6 +310,7 @@ Example: Add a request header
310
310
request.headers['New-Header'] ='Some Value'
311
311
312
312
driver.request_interceptor = interceptor
313
+
driver.get(...)
313
314
314
315
# All requests will now contain New-Header
315
316
@@ -327,6 +328,7 @@ Duplicate header names are permitted in an HTTP request, so before setting the r
327
328
request.headers['Referer'] ='some_referer'# Spoof the referer
328
329
329
330
driver.request_interceptor = interceptor
331
+
driver.get(...)
330
332
331
333
# All requests will now use 'some_referer' for the referer
332
334
@@ -340,6 +342,7 @@ Example: Add a response header
340
342
response.headers['New-Header'] ='Some Value'
341
343
342
344
driver.response_interceptor = interceptor
345
+
driver.get(...)
343
346
344
347
# Responses from https://server.com/some/path will now contain New-Header
345
348
@@ -356,6 +359,7 @@ Request parameters work differently to headers in that they are calculated when
356
359
request.params = params
357
360
358
361
driver.request_interceptor = interceptor
362
+
driver.get(...)
359
363
360
364
# foo=bar will be added to all requests
361
365
@@ -381,6 +385,7 @@ Example: Update JSON in a POST request body
If you find you're still not getting the performance you want after limiting request capture, you might try switching to the `mitmproxy backend`_.
492
-
493
-
.. _`mitmproxy backend`: #backends
494
-
495
498
Proxies
496
499
~~~~~~~
497
500
498
-
If the site you are accessing sits behind a proxy server you can tell Selenium Wire about that proxy server in the options you pass to the webdriver instance. The configuration takes the following format:
501
+
If the site you are accessing sits behind a proxy server you can tell Selenium Wire about that proxy server in the options you pass to the webdriver.
0 commit comments