Puppeteer & WebdriverIO
WebdriverIO is a popular Automation Test Framework for Node.js.
It has built-in support for both WebDriver
and the Chrome DevTools Protocol
.
To get started, please install WebdriverIO:
Next, create a simple test suite with the command below. Follow the steps to set up a test suite.
This will generate some files that we can use to run a Puppeteer test with WebdriverIO on the TestingBot browser grid.
Run your first test
Create a new spec file with the example code below:
import { format } from 'util'
import { remote } from 'webdriverio'
(async () => {
const browser = await remote({
capabilities: {
'wdio:devtoolsOptions': {
browserWSEndpoint: format(
`wss://cloud.testingbot.com?key=%s&secret=%s&browserName=chrome&browserVersion=latest`,
process.env.TESTINGBOT_KEY,
process.env.TESTINGBOT_SECRET
)
}
}
})
await browser.url('https://testingbot.com')
const title = await browser.getTitle()
console.log(title) // returns "Cross Browser Testing and Mobile App Testing | TestingBot"
await browser.deleteSession()
})()
You can find more information about WebdriverIO's Puppeteer support in the WebdriverIO documentation.
Specifying browser and version
To specify on which browser and version your WebdriverIO + Puppeteer test should run, you can include both a browserName
and browserVersion
in the browserWSEndpoint
URL.
Select a browser & version