I’ve added a route to send CDP command to Chromedriver.
CDP stands for Chrome Devtools Protocol. It provides commands to handle a browser via the protocol. Some commands can be alternatives to WebDriver spec, but they have their own more useful commands.
It is available over WebSocket. You can find CDP clients in the internet, but Chromedriver also has a command to proxy CDP commands to a browser. It is /session/:sessionId/:vendor/cdp/execute route. Appium beta (it will be included in 1.18.0, I assume) has it. You can send the command to Chromedriver (Web Context) if the driver supports the path.
Below is an example to send a command to the command via Ruby binding. (ruby_lib_core 3.7.0 has the command for Android).
> @driver.execute_cdp 'Page.getResourceTree'
=> {"frameTree"=>
{"frame"=>{"id"=>"39B491DE0055515F0F352E11054854F9", "loaderId"=>"3E11DD1F2E9E020331C94E2E02E608E7", "mimeType"=>"text/plain", "securityOrigin"=>"://", "url"=>"data:,"},
"resources"=>[{"contentSize"=>0, "mimeType"=>"text/plain", "type"=>"Document", "url"=>"data:,"}]}}
It can give parameters like @driver.execute_cdp 'Page.captureScreenshot', { quality: 50, format: 'jpeg' }.
I found the cpb command was in Java, Python and Ruby clients in Selenium bindings. So, if your clients are them, you will be able to try it out. If they are not in Appium bindings, we’ll be always welcome to your commitments 🙂
Happy testing 🙂
p.s. https://source.chromium.org/chromium/chromium/src/+/master:chrome/test/chromedriver/server/http_handler.cc;l=885?q=%2Fcdp%2Fexecute is the path to CDP command in chromium code.