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, failOnStatusCode: nil, headers: nil, ignoreHTTPSErrors: 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, failOnStatusCode: nil, headers: nil, ignoreHTTPSErrors: 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 |
# File 'lib/playwright_api/api_request_context.rb', line 11 def delete( url, failOnStatusCode: nil, headers: nil, ignoreHTTPSErrors: 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.
24 25 26 |
# File 'lib/playwright_api/api_request_context.rb', line 24 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.
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/playwright_api/api_request_context.rb', line 30 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.
47 48 49 50 51 52 53 54 55 |
# File 'lib/playwright_api/api_request_context.rb', line 47 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.
60 61 62 63 64 65 66 67 68 |
# File 'lib/playwright_api/api_request_context.rb', line 60 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 –
138 139 140 |
# File 'lib/playwright_api/api_request_context.rb', line 138 def off(event, callback) event_emitter_proxy.off(event, callback) end |
#on(event, callback) ⇒ Object
– inherited from EventEmitter –
132 133 134 |
# File 'lib/playwright_api/api_request_context.rb', line 132 def on(event, callback) event_emitter_proxy.on(event, callback) end |
#once(event, callback) ⇒ Object
– inherited from EventEmitter –
126 127 128 |
# File 'lib/playwright_api/api_request_context.rb', line 126 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.
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/playwright_api/api_request_context.rb', line 73 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.
89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/playwright_api/api_request_context.rb', line 89 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.
105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/playwright_api/api_request_context.rb', line 105 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.
120 121 122 |
# File 'lib/playwright_api/api_request_context.rb', line 120 def storage_state(path: nil) raise NotImplementedError.new('storage_state is not implemented yet.') end |