@testplane/devtools
v8.32.2
Published
A Chrome DevTools protocol binding that maps WebDriver commands into Chrome DevTools commands using Puppeteer
Downloads
214
Keywords
Readme
[!WARNING] WebdriverIO is deprecating the use of Chrome Devtools as automation protocol through a WebDriver like interface. Instead, you can use the
getPuppeteer
command to get ahold of a Puppeteer instance for Chrome Devtools introspection and automation.
DevTools
A Chrome DevTools protocol binding that maps WebDriver commands into Chrome DevTools commands using Puppeteer
This package provides a low level interface to run browser automation scripts based on the WebDriver protocol. If you are looking for a tool to automate Chrome or Firefox you should look up Puppeteer. This is suppose to be used by the WebdriverIO package in order to run its automation on the Chrome DevTools protocol.
Install
npm i webdriverio
Example
The following example demonstrates how WebdriverIO can be used with the devtools
package as automation binding using the automationProtocol
option:
import { remote } from 'webdriverio'
const browser = await remote({
automationProtocol: 'devtools',
capabilities: {
browserName: 'chrome',
'wdio:devtoolsOptions': {
headless: true
}
}
})
await browser.url('https://webdriver.io')
/**
* run Puppeteer code
*/
const puppeteer = await browser.getPuppeteer()
const page = (await puppeteer.pages())[0]
await page.setRequestInterception(true)
page.on('request', interceptedRequest => {
if (interceptedRequest.url().endsWith('webdriverio.png')) {
return interceptedRequest.continue({
url: 'https://user-images.githubusercontent.com/10379601/29446482-04f7036a-841f-11e7-9872-91d1fc2ea683.png'
})
}
interceptedRequest.continue()
})
// continue with WebDriver commands
await browser.url('https://v6.webdriver.io')
await browser.pause(2000)
/**
* now on the https://v6.webdriver.io page you see the Puppeteer logo
* instead of the WebdriverIO one
*/
await browser.deleteSession()
wdio:devtoolsOptions
Capability
In order to set Puppeteer specific configurations you can use the wdio:devtoolsOptions
capability which is a custom property (compliant to the WebDriver protocol), e.g.:
{
browserName: 'chrome',
'wdio:devtoolsOptions': {
headless: true,
defaultViewport: {
width: 800,
height: 600,
deviceScaleFactor: 1,
isMobile: false
}
}
}
Commands
The following commands are already supported:
- [x] newSession
- [x] deleteSession
- [x] status
- [x] getTimeouts
- [x] setTimeouts
- [x] getUrl
- [x] navigateTo
- [x] back
- [x] forward
- [x] refresh
- [x] getTitle
- [x] getWindowHandle
- [x] closeWindow
- [x] switchToWindow
- [x] createWindow
- [x] getWindowHandles
- [x] switchToFrame
- [x] switchToParentFrame
- [x] getWindowRect
- [x] setWindowRect
- [ ] maximizeWindow (not possible with Puppeteer)
- [ ] minimizeWindow (not possible with Puppeteer)
- [ ] fullscreenWindow (not possible with Puppeteer)
- [x] findElement
- [x] findElements
- [x] findElementFromElement
- [x] findElementsFromElement
- [x] getActiveElement
- [x] isElementSelected
- [x] isElementDisplayed
- [x] getElementAttribute
- [x] getElementProperty
- [x] getElementCSSValue
- [x] getElementText
- [x] getElementTagName
- [x] getElementRect
- [x] isElementEnabled
- [x] elementClick
- [x] elementClear
- [x] elementSendKeys
- [x] getPageSource
- [x] executeScript
- [x] executeAsyncScript
- [x] getAllCookies
- [x] getNamedCookie
- [x] addCookie
- [x] deleteAllCookies
- [x] deleteCookie
- [x] performActions
- [x] releaseActions
- [x] dismissAlert
- [x] acceptAlert
- [x] getAlertText
- [x] sendAlertText
- [x] takeScreenshot
- [x] takeElementScreenshot
Selector Strategies
- [x] CSS Selector
- [x] Link Text
- [x] Partial Link Text
- [x] Tag Name
- [x] XPath
Browser
- [x] Chrome
- [x] Firefox (nightly only)
- [x] Edge
- [ ] Safari