Path: blob/trunk/javascript/selenium-webdriver/test/bidi/bidi_test.js
2885 views
// Licensed to the Software Freedom Conservancy (SFC) under one1// or more contributor license agreements. See the NOTICE file2// distributed with this work for additional information3// regarding copyright ownership. The SFC licenses this file4// to you under the Apache License, Version 2.0 (the5// "License"); you may not use this file except in compliance6// with the License. You may obtain a copy of the License at7//8// http://www.apache.org/licenses/LICENSE-2.09//10// Unless required by applicable law or agreed to in writing,11// software distributed under the License is distributed on an12// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13// KIND, either express or implied. See the License for the14// specific language governing permissions and limitations15// under the License.1617'use strict'1819const assert = require('node:assert')20const { Browser } = require('selenium-webdriver')21const { Pages, suite } = require('../../lib/test')22const logInspector = require('selenium-webdriver/bidi/logInspector')23const BrowsingContext = require('selenium-webdriver/bidi/browsingContext')24const until = require('selenium-webdriver/lib/until')2526suite(27function (env) {28let driver29let inspector3031beforeEach(async function () {32driver = await env.builder().build()33inspector = await logInspector(driver)34})3536afterEach(async function () {37await inspector.close()38await driver.quit()39})4041describe('Integration Tests', function () {42it('can navigate and listen to errors', async function () {43let logEntry = null4445await inspector.onJavascriptException(function (log) {46logEntry = log47})4849const id = await driver.getWindowHandle()50const browsingContext = await BrowsingContext(driver, {51browsingContextId: id,52})53const info = await browsingContext.navigate(Pages.logEntryAdded)5455assert.notEqual(browsingContext.id, null)56assert.notEqual(info.navigationId, null)57assert(info.url.includes('/bidi/logEntryAdded.html'))5859await driver.wait(until.urlIs(Pages.logEntryAdded))60await driver.findElement({ id: 'jsException' }).click()6162assert.equal(logEntry.text, 'Error: Not working')63assert.equal(logEntry.type, 'javascript')64assert.equal(logEntry.level, 'error')6566await browsingContext.close()67})68})69},70{ browsers: [Browser.FIREFOX] },71)727374