Skip to content

Commit 4ad6726

Browse files
authored
[js][bidi] Add test for using BiDi to navigate and get exceptions (#11476)
1 parent 21fe296 commit 4ad6726

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

javascript/node/selenium-webdriver/test/bidi/bidi_test.js

+31
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const { Browser } = require('../../')
2323
const { Pages, suite } = require('../../lib/test')
2424
const logInspector = require('../../bidi/logInspector')
2525
const BrowsingContext = require('../../bidi/browsingContext')
26+
const until = require('../../lib/until')
2627

2728
suite(
2829
function (env) {
@@ -209,6 +210,36 @@ suite(
209210
await assert.rejects(window2.getTree(), { message: 'no such frame' })
210211
})
211212
})
213+
214+
describe('Integration Tests', function () {
215+
it('can navigate and listen to errors', async function () {
216+
let logEntry = null
217+
const inspector = await logInspector(driver)
218+
await inspector.onJavascriptException(function (log) {
219+
logEntry = log
220+
})
221+
222+
const id = await driver.getWindowHandle()
223+
const browsingContext = await BrowsingContext(driver, {
224+
browsingContextId: id,
225+
})
226+
const info = await browsingContext.navigate(Pages.logEntryAdded)
227+
228+
assert.notEqual(browsingContext.id, null)
229+
assert.equal(info.navigationId, null)
230+
assert(info.url.includes('/bidi/logEntryAdded.html'))
231+
232+
await driver.wait(until.urlIs(Pages.logEntryAdded))
233+
await driver.findElement({ id: 'jsException' }).click()
234+
235+
assert.equal(logEntry.text, 'Error: Not working')
236+
assert.equal(logEntry.type, 'javascript')
237+
assert.equal(logEntry.level, 'error')
238+
239+
await inspector.close()
240+
await browsingContext.close()
241+
})
242+
})
212243
},
213244
{ browsers: [Browser.FIREFOX] }
214245
)

0 commit comments

Comments
 (0)