Skip to content

Commit

Permalink
add example for bidi
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed Dec 13, 2022
1 parent 716110f commit 933751d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
28 changes: 28 additions & 0 deletions examples/bidi/logging.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { remote } from '../../packages/webdriverio/build/index.js'

/**
* this little script demonstrates how to run a session
* on the WebDriver Bidi protocol.
*/
const browser = await remote({
capabilities: {
webSocketUrl: true,
browserName: 'chrome'
}
})

console.log(browser.capabilities)

await browser.send({
method: 'session.subscribe',
params: { events: ['log.entryAdded'] }
})

/**
* returns: {"method":"log.entryAdded","params":{"type":"console","method":"log","realm":null,"args":[{"type":"string","value":"Hello Bidi"}],"level":"info","text":"Hello Bidi","timestamp":1657282076037}}
*/
browser.on('message', (data) => console.log('received %s', data))

await browser.executeScript('console.log("Hello Bidi")', [])
// await browser.debug()
await browser.deleteSession()
3 changes: 3 additions & 0 deletions examples/bidi/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}

0 comments on commit 933751d

Please sign in to comment.