Using Chrome DevTools protocol
Both ChromeDriver and EdgeDriver expose some specific commands for working with their respective browsers.
When using ChromeDriver or EdgeDriver it is now possible to execute commands via the Chrome DevTools protocol.
Here's the full list of commands available on the .chrome
namespace on the browser
object:
browser.chrome:
- .launchApp()
- .getNetworkConditions()
- .setNetworkConditions()
- .sendDevToolsCommand()
- .sendAndGetDevToolsCommand()
- .setPermission()
- .setDownloadPath()
- .getCastSinks()
- .setCastSinkToUse()
- .startCastTabMirroring()
- .getCastIssueMessage()
- .stopCasting()
More info:
- selenium-webdriver/chromium (class Driver)
- selenium-webdriver/chrome (class Driver)
- selenium-webdriver/edge (class Driver)
Example
describe('Chrome DevTools Example', function() {
it ('using CDP DOM Snapshot', async function() {
const dom = await browser.chrome.sendAndGetDevToolsCommand('DOMSnapshot.captureSnapshot', {
computedStyles: []
});
console.log('DOM', dom)
});
});