Class: Playwright::APIRequestContext
- Inherits:
-
PlaywrightApi
- Object
- PlaywrightApi
- Playwright::APIRequestContext
- Defined in:
- lib/playwright_api/api_request_context.rb
Overview
This API is used for the Web API testing. You can use it to trigger API endpoints, configure micro-services, prepare environment or the service to your e2e test. When used on ‘Page` or a `BrowserContext`, this API will automatically use the cookies from the corresponding `BrowserContext`. This means that if you log in using this API, your e2e test will be logged in and vice versa.
Direct Known Subclasses
Instance Method Summary collapse
-
#delete(url, data: nil, failOnStatusCode: nil, form: nil, headers: nil, ignoreHTTPSErrors: nil, multipart: nil, params: nil, timeout: nil) ⇒ Object
Sends HTTP(S) [DELETE](developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE) request and returns its response.
-
#dispose ⇒ Object
All responses returned by [‘method: APIRequestContext.get`] and similar methods are stored in the memory, so that you can later call [`method: APIResponse.body`].
-
#fetch(urlOrRequest, data: nil, failOnStatusCode: nil, form: nil, headers: nil, ignoreHTTPSErrors: nil, method: nil, multipart: nil, params: nil, timeout: nil) ⇒ Object
Sends HTTP(S) request and returns its response.
-
#get(url, failOnStatusCode: nil, headers: nil, ignoreHTTPSErrors: nil, params: nil, timeout: nil) ⇒ Object
Sends HTTP(S) [GET](developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET) request and returns its response.
-
#head(url, failOnStatusCode: nil, headers: nil, ignoreHTTPSErrors: nil, params: nil, timeout: nil) ⇒ Object
Sends HTTP(S) [HEAD](developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD) request and returns its response.
-
#off(event, callback) ⇒ Object
– inherited from EventEmitter –.
-
#on(event, callback) ⇒ Object
– inherited from EventEmitter –.
-
#once(event, callback) ⇒ Object
– inherited from EventEmitter –.
-
#patch(url, data: nil, failOnStatusCode: nil, form: nil, headers: nil, ignoreHTTPSErrors: nil, multipart: nil, params: nil, timeout: nil) ⇒ Object
Sends HTTP(S) [PATCH](developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH) request and returns its response.
-
#post(url, data: nil, failOnStatusCode: nil, form: nil, headers: nil, ignoreHTTPSErrors: nil, multipart: nil, params: nil, timeout: nil) ⇒ Object
Sends HTTP(S) [POST](developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) request and returns its response.
-
#put(url, data: nil, failOnStatusCode: nil, form: nil, headers: nil, ignoreHTTPSErrors: nil, multipart: nil, params: nil, timeout: nil) ⇒ Object
Sends HTTP(S) [PUT](developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT) request and returns its response.
-
#storage_state(path: nil) ⇒ Object
Returns storage state for this request context, contains current cookies and local storage snapshot if it was passed to the constructor.
Methods inherited from PlaywrightApi
Constructor Details
This class inherits a constructor from Playwright::PlaywrightApi
Instance Method Details
#delete(url, data: nil, failOnStatusCode: nil, form: nil, headers: nil, ignoreHTTPSErrors: nil, multipart: nil, params: nil, timeout: nil) ⇒ Object
Sends HTTP(S) [DELETE](developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE) request and returns its response. The method will populate request cookies from the context and update context cookies from the response. The method will automatically follow redirects.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/playwright_api/api_request_context.rb', line 11 def delete( url, data: nil, failOnStatusCode: nil, form: nil, headers: nil, ignoreHTTPSErrors: nil, multipart: nil, params: nil, timeout: nil) raise NotImplementedError.new('delete is not implemented yet.') end |
#dispose ⇒ Object
All responses returned by [‘method: APIRequestContext.get`] and similar methods are stored in the memory, so that you can later call [`method: APIResponse.body`]. This method discards all stored responses, and makes
- ‘method: APIResponse.body`
-
throw “Response disposed” error.
27 28 29 |
# File 'lib/playwright_api/api_request_context.rb', line 27 def dispose raise NotImplementedError.new('dispose is not implemented yet.') end |
#fetch(urlOrRequest, data: nil, failOnStatusCode: nil, form: nil, headers: nil, ignoreHTTPSErrors: nil, method: nil, multipart: nil, params: nil, timeout: nil) ⇒ Object
Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update context cookies from the response. The method will automatically follow redirects.
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/playwright_api/api_request_context.rb', line 33 def fetch( urlOrRequest, data: nil, failOnStatusCode: nil, form: nil, headers: nil, ignoreHTTPSErrors: nil, method: nil, multipart: nil, params: nil, timeout: nil) raise NotImplementedError.new('fetch is not implemented yet.') end |
#get(url, failOnStatusCode: nil, headers: nil, ignoreHTTPSErrors: nil, params: nil, timeout: nil) ⇒ Object
Sends HTTP(S) [GET](developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET) request and returns its response. The method will populate request cookies from the context and update context cookies from the response. The method will automatically follow redirects.
50 51 52 53 54 55 56 57 58 |
# File 'lib/playwright_api/api_request_context.rb', line 50 def get( url, failOnStatusCode: nil, headers: nil, ignoreHTTPSErrors: nil, params: nil, timeout: nil) raise NotImplementedError.new('get is not implemented yet.') end |
#head(url, failOnStatusCode: nil, headers: nil, ignoreHTTPSErrors: nil, params: nil, timeout: nil) ⇒ Object
Sends HTTP(S) [HEAD](developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD) request and returns its response. The method will populate request cookies from the context and update context cookies from the response. The method will automatically follow redirects.
63 64 65 66 67 68 69 70 71 |
# File 'lib/playwright_api/api_request_context.rb', line 63 def head( url, failOnStatusCode: nil, headers: nil, ignoreHTTPSErrors: nil, params: nil, timeout: nil) raise NotImplementedError.new('head is not implemented yet.') end |
#off(event, callback) ⇒ Object
– inherited from EventEmitter –
129 130 131 |
# File 'lib/playwright_api/api_request_context.rb', line 129 def off(event, callback) event_emitter_proxy.off(event, callback) end |
#on(event, callback) ⇒ Object
– inherited from EventEmitter –
141 142 143 |
# File 'lib/playwright_api/api_request_context.rb', line 141 def on(event, callback) event_emitter_proxy.on(event, callback) end |
#once(event, callback) ⇒ Object
– inherited from EventEmitter –
135 136 137 |
# File 'lib/playwright_api/api_request_context.rb', line 135 def once(event, callback) event_emitter_proxy.once(event, callback) end |
#patch(url, data: nil, failOnStatusCode: nil, form: nil, headers: nil, ignoreHTTPSErrors: nil, multipart: nil, params: nil, timeout: nil) ⇒ Object
Sends HTTP(S) [PATCH](developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH) request and returns its response. The method will populate request cookies from the context and update context cookies from the response. The method will automatically follow redirects.
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/playwright_api/api_request_context.rb', line 76 def patch( url, data: nil, failOnStatusCode: nil, form: nil, headers: nil, ignoreHTTPSErrors: nil, multipart: nil, params: nil, timeout: nil) raise NotImplementedError.new('patch is not implemented yet.') end |
#post(url, data: nil, failOnStatusCode: nil, form: nil, headers: nil, ignoreHTTPSErrors: nil, multipart: nil, params: nil, timeout: nil) ⇒ Object
Sends HTTP(S) [POST](developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) request and returns its response. The method will populate request cookies from the context and update context cookies from the response. The method will automatically follow redirects.
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/playwright_api/api_request_context.rb', line 92 def post( url, data: nil, failOnStatusCode: nil, form: nil, headers: nil, ignoreHTTPSErrors: nil, multipart: nil, params: nil, timeout: nil) raise NotImplementedError.new('post is not implemented yet.') end |
#put(url, data: nil, failOnStatusCode: nil, form: nil, headers: nil, ignoreHTTPSErrors: nil, multipart: nil, params: nil, timeout: nil) ⇒ Object
Sends HTTP(S) [PUT](developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT) request and returns its response. The method will populate request cookies from the context and update context cookies from the response. The method will automatically follow redirects.
108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/playwright_api/api_request_context.rb', line 108 def put( url, data: nil, failOnStatusCode: nil, form: nil, headers: nil, ignoreHTTPSErrors: nil, multipart: nil, params: nil, timeout: nil) raise NotImplementedError.new('put is not implemented yet.') end |
#storage_state(path: nil) ⇒ Object
Returns storage state for this request context, contains current cookies and local storage snapshot if it was passed to the constructor.
123 124 125 |
# File 'lib/playwright_api/api_request_context.rb', line 123 def storage_state(path: nil) raise NotImplementedError.new('storage_state is not implemented yet.') end |