1- const { suite} = require ( 'selenium-webdriver/testing' ) ;
21const assert = require ( "assert" ) ;
2+ const { until, Builder} = require ( 'selenium-webdriver' ) ;
33const firefox = require ( 'selenium-webdriver/firefox' ) ;
44const LogInspector = require ( 'selenium-webdriver/bidi/logInspector' ) ;
55const BrowsingContext = require ( 'selenium-webdriver/bidi/browsingContext' ) ;
6- const { until} = require ( 'selenium-webdriver' ) ;
7-
8- suite ( function ( env ) {
9- describe ( 'Integration Tests' , function ( ) {
10- let driver
11-
12- beforeEach ( async function ( ) {
13- driver = await env
14- . builder ( )
15- . setFirefoxOptions ( new firefox . Options ( ) . enableBidi ( ) )
16- . build ( )
17- } )
18-
19- afterEach ( async function ( ) {
20- await driver . quit ( )
21- } )
22-
23- it ( 'test navigate and listen to errors' , async function ( ) {
24- let logEntry = null
25- const inspector = await LogInspector ( driver )
26- await inspector . onJavascriptException ( function ( log ) {
27- logEntry = log
28- } )
29-
30- const id = await driver . getWindowHandle ( )
31- const browsingContext = await BrowsingContext ( driver , {
32- browsingContextId : id ,
33- } )
34-
35- let info = await browsingContext . navigate ( 'https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html' )
36-
37- assert . notEqual ( browsingContext . id , null )
38- assert . notEqual ( info . navigationId , null )
39- assert ( info . url . includes ( '/bidi/logEntryAdded.html' ) )
40-
41- await driver . wait ( until . urlIs ( 'https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html' ) )
42- await driver . findElement ( { id : 'jsException' } ) . click ( )
43-
44- assert . equal ( logEntry . text , 'Error: Not working' )
45- assert . equal ( logEntry . type , 'javascript' )
46- assert . equal ( logEntry . level , 'error' )
47-
48- await inspector . close ( )
49- await browsingContext . close ( )
50- } )
6+
7+ describe ( 'Integration Tests' , function ( ) {
8+ let driver
9+
10+ beforeEach ( async function ( ) {
11+ driver = new Builder ( )
12+ . forBrowser ( 'firefox' )
13+ . setFirefoxOptions ( new firefox . Options ( ) . enableBidi ( ) )
14+ . build ( )
15+ } )
16+
17+ afterEach ( async function ( ) {
18+ await driver . quit ( )
19+ } )
20+
21+ it ( 'test navigate and listen to errors' , async function ( ) {
22+ let logEntry = null
23+ const inspector = await LogInspector ( driver )
24+ await inspector . onJavascriptException ( function ( log ) {
25+ logEntry = log
26+ } )
27+
28+ const id = await driver . getWindowHandle ( )
29+ const browsingContext = await BrowsingContext ( driver , {
30+ browsingContextId : id ,
5131 } )
52- } , { browsers : [ 'firefox' ] } )
32+
33+ let info = await browsingContext . navigate ( 'https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html' )
34+
35+ assert . notEqual ( browsingContext . id , null )
36+ assert . notEqual ( info . navigationId , null )
37+ assert ( info . url . includes ( '/bidi/logEntryAdded.html' ) )
38+
39+ await driver . wait ( until . urlIs ( 'https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html' ) )
40+ await driver . findElement ( { id : 'jsException' } ) . click ( )
41+
42+ assert . equal ( logEntry . text , 'Error: Not working' )
43+ assert . equal ( logEntry . type , 'javascript' )
44+ assert . equal ( logEntry . level , 'error' )
45+
46+ await inspector . close ( )
47+ await browsingContext . close ( )
48+ } )
49+ } )
0 commit comments