Class: Playwright::ConsoleMessage
- Inherits:
-
PlaywrightApi
- Object
- PlaywrightApi
- Playwright::ConsoleMessage
- Defined in:
- lib/playwright_api/console_message.rb
Overview
‘ConsoleMessage` objects are dispatched by page via the [`event: Page.console`] event. For each console messages logged in the page there will be corresponding event in the Playwright context.
“‘python sync # Listen for all console logs page.on(“console”, lambda msg: print(msg.text))
# Listen for all console events and handle errors page.on(“console”, lambda msg: print(f“error: msgmsg.text”) if msg.type == “error” else None)
# Get the next console log with page.expect_console_message() as msg_info:
# Issue console.log inside the page
page.evaluate("console.log('hello', 42, { foo: 'bar' })")
msg = msg_info.value
# Deconstruct print arguments msg.args.json_value() # hello msg.args.json_value() # 42 “‘
Instance Method Summary collapse
-
#args ⇒ Object
List of arguments passed to a ‘console` function call.
- #location ⇒ Object
-
#off(event, callback) ⇒ Object
– inherited from EventEmitter –.
-
#on(event, callback) ⇒ Object
– inherited from EventEmitter –.
-
#once(event, callback) ⇒ Object
– inherited from EventEmitter –.
-
#text ⇒ Object
The text of the console message.
-
#type ⇒ Object
One of the following values: ‘’log’‘, `’debug’‘, `’info’‘, `’error’‘, `’warning’‘, `’dir’‘, `’dirxml’‘, `’table’‘, `’trace’‘, `’clear’‘, `’startGroup’‘, `’startGroupCollapsed’‘, `’endGroup’‘, `’assert’‘, `’profile’‘, `’profileEnd’‘, `’count’‘, `’timeEnd’‘.
Methods inherited from PlaywrightApi
Constructor Details
This class inherits a constructor from Playwright::PlaywrightApi
Instance Method Details
#args ⇒ Object
List of arguments passed to a ‘console` function call. See also [`event: Page.console`].
25 26 27 |
# File 'lib/playwright_api/console_message.rb', line 25 def args wrap_impl(@impl.args) end |
#location ⇒ Object
29 30 31 |
# File 'lib/playwright_api/console_message.rb', line 29 def location wrap_impl(@impl.location) end |
#off(event, callback) ⇒ Object
– inherited from EventEmitter –
59 60 61 |
# File 'lib/playwright_api/console_message.rb', line 59 def off(event, callback) event_emitter_proxy.off(event, callback) end |
#on(event, callback) ⇒ Object
– inherited from EventEmitter –
53 54 55 |
# File 'lib/playwright_api/console_message.rb', line 53 def on(event, callback) event_emitter_proxy.on(event, callback) end |
#once(event, callback) ⇒ Object
– inherited from EventEmitter –
47 48 49 |
# File 'lib/playwright_api/console_message.rb', line 47 def once(event, callback) event_emitter_proxy.once(event, callback) end |
#text ⇒ Object
The text of the console message.
34 35 36 |
# File 'lib/playwright_api/console_message.rb', line 34 def text wrap_impl(@impl.text) end |
#type ⇒ Object
One of the following values: ‘’log’‘, `’debug’‘, `’info’‘, `’error’‘, `’warning’‘, `’dir’‘, `’dirxml’‘, `’table’‘, `’trace’‘, `’clear’‘, `’startGroup’‘, `’startGroupCollapsed’‘, `’endGroup’‘, `’assert’‘, `’profile’‘, `’profileEnd’‘, `’count’‘, `’timeEnd’‘.
41 42 43 |
# File 'lib/playwright_api/console_message.rb', line 41 def type wrap_impl(@impl.type) end |