Class: Playwright::FetchRequest
- Inherits:
-
PlaywrightApi
- Object
- PlaywrightApi
- Playwright::FetchRequest
- Defined in:
- lib/playwright_api/fetch_request.rb
Overview
This API is used for 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.
Instance Method Summary collapse
-
#dispose ⇒ Object
All responses received through [‘method: FetchRequest.fetch`], [`method: FetchRequest.get`], [`method: FetchRequest.post`] and other methods are stored in the memory, so that you can later call [`method: FetchResponse.body`].
-
#fetch(urlOrRequest, data: nil, failOnStatusCode: nil, headers: nil, method: nil, params: nil, timeout: nil) ⇒ Object
Sends HTTP(S) fetch and returns its response.
-
#get(urlOrRequest, failOnStatusCode: nil, headers: nil, params: nil, timeout: nil) ⇒ Object
Sends HTTP(S) GET 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 –.
-
#post(urlOrRequest, data: nil, failOnStatusCode: nil, headers: nil, params: nil, timeout: nil) ⇒ Object
Sends HTTP(S) fetch and returns its response.
Methods inherited from PlaywrightApi
Constructor Details
This class inherits a constructor from Playwright::PlaywrightApi
Instance Method Details
#dispose ⇒ Object
All responses received through [‘method: FetchRequest.fetch`], [`method: FetchRequest.get`],
- ‘method: FetchRequest.post`
-
and other methods are stored in the memory, so that you can later call
- ‘method: FetchResponse.body`]. This method discards all stored responses, and makes [`method: FetchResponse.body`
-
throw “Response disposed” error.
12 13 14 |
# File 'lib/playwright_api/fetch_request.rb', line 12 def dispose raise NotImplementedError.new('dispose is not implemented yet.') end |
#fetch(urlOrRequest, data: nil, failOnStatusCode: nil, headers: nil, method: nil, params: nil, timeout: nil) ⇒ Object
Sends HTTP(S) fetch and returns its response. The method will populate fetch cookies from the context and update context cookies from the response. The method will automatically follow redirects.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/playwright_api/fetch_request.rb', line 18 def fetch( urlOrRequest, data: nil, failOnStatusCode: nil, headers: nil, method: nil, params: nil, timeout: nil) raise NotImplementedError.new('fetch is not implemented yet.') end |
#get(urlOrRequest, failOnStatusCode: nil, headers: nil, params: nil, timeout: nil) ⇒ Object
Sends HTTP(S) GET request and returns its response. The method will populate fetch cookies from the context and update context cookies from the response. The method will automatically follow redirects.
31 32 33 34 35 36 37 38 |
# File 'lib/playwright_api/fetch_request.rb', line 31 def get( urlOrRequest, failOnStatusCode: nil, headers: nil, params: nil, timeout: nil) raise NotImplementedError.new('get is not implemented yet.') end |
#off(event, callback) ⇒ Object
– inherited from EventEmitter –
54 55 56 |
# File 'lib/playwright_api/fetch_request.rb', line 54 def off(event, callback) event_emitter_proxy.off(event, callback) end |
#on(event, callback) ⇒ Object
– inherited from EventEmitter –
66 67 68 |
# File 'lib/playwright_api/fetch_request.rb', line 66 def on(event, callback) event_emitter_proxy.on(event, callback) end |
#once(event, callback) ⇒ Object
– inherited from EventEmitter –
60 61 62 |
# File 'lib/playwright_api/fetch_request.rb', line 60 def once(event, callback) event_emitter_proxy.once(event, callback) end |
#post(urlOrRequest, data: nil, failOnStatusCode: nil, headers: nil, params: nil, timeout: nil) ⇒ Object
Sends HTTP(S) fetch and returns its response. The method will populate fetch cookies from the context and update context cookies from the response. The method will automatically follow redirects.
42 43 44 45 46 47 48 49 50 |
# File 'lib/playwright_api/fetch_request.rb', line 42 def post( urlOrRequest, data: nil, failOnStatusCode: nil, headers: nil, params: nil, timeout: nil) raise NotImplementedError.new('post is not implemented yet.') end |