Webview.cdp readonly


Access a Chrome DevTools Protocol (CDP) function as a Lua table, calling it with a JSON string.
The CDP function will return a Task that, once finished, will return two values :

  • A boolean value indicating if the Chrome DevTools function succeeded
  • A string value representing either an error message in case of failure, or the result as a JSON encoded string

Notes

  • The Chrome DevTools Protocol is a set of tools and APIs that allow developers to interact with, inspect, debug, and profile Chromium-based browsers like the Webview.
  • You can access CDP functions seamlessly with this property, like Webview.cdp.Log.clear() to call Log.clear() CDP method
  • See Official documentation for a full reference.

Example

local ui = require "ui" require "webview" local win = ui.Window("Chrome Devtools Protocol example", "fixed", 320, 240) local wv = ui.Webview(win, 0, 0, 320, 200) local button = ui.Button(win, "Send a message to console log") button:center() button.y = 206 win:center() function button:onClick() local success, result = await(wv.cdp.Runtime.evaluate('{"expression":"console.log(\'Hello from LuaRT !\')"}')) if not success then ui.error(result) else ui.info("Message sent !") end end function wv:onReady() self:opendevtools() self:loadstring([[ <!DOCTYPE html> <html> <body> In the DevTools window, click on the Console tab to see the message. </body> </html>]]) end ui.run(win):wait()