Skip to content

Commit a0210e3

Browse files
committed
[bidi][js] Fix log inspector test
1 parent 33c6b78 commit a0210e3

File tree

1 file changed

+51
-72
lines changed

1 file changed

+51
-72
lines changed

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

Lines changed: 51 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,19 @@ suite(
3737

3838
describe('Log Inspector', function () {
3939
it('can listen to console log', async function () {
40-
let logEntry = null
4140
const inspector = await logInspector(driver)
4241
await inspector.onConsoleEntry(function (log) {
43-
logEntry = log
42+
assert.equal(log.text, 'Hello, world!')
43+
assert.equal(log.realm, null)
44+
assert.equal(log.type, 'console')
45+
assert.equal(log.level, 'info')
46+
assert.equal(log.method, 'log')
47+
assert.equal(log.args.length, 1)
4448
})
4549

4650
await driver.get(Pages.logEntryAdded)
4751
await driver.findElement({ id: 'consoleLog' }).click()
4852

49-
assert.equal(logEntry.text, 'Hello, world!')
50-
assert.equal(logEntry.realm, null)
51-
assert.equal(logEntry.type, 'console')
52-
assert.equal(logEntry.level, 'info')
53-
assert.equal(logEntry.method, 'log')
54-
assert.equal(logEntry.stackTrace, null)
55-
assert.equal(logEntry.args.length, 1)
56-
5753
await inspector.close()
5854
})
5955

@@ -62,26 +58,23 @@ suite(
6258
const inspector = await logInspector(driver)
6359
await inspector.onConsoleEntry(function (log) {
6460
logEntry = log
61+
assert.equal(logEntry.text, 'Hello, world!')
62+
assert.equal(logEntry.realm, null)
63+
assert.equal(logEntry.type, 'console')
64+
assert.equal(logEntry.level, 'info')
65+
assert.equal(logEntry.method, 'log')
66+
assert.equal(logEntry.args.length, 1)
6567
})
6668

6769
let logEntryText = null
6870
await inspector.onConsoleEntry(function (log) {
6971
logEntryText = log.text
72+
assert.equal(logEntryText, 'Hello, world!')
7073
})
7174

7275
await driver.get(Pages.logEntryAdded)
7376
await driver.findElement({ id: 'consoleLog' }).click()
7477

75-
assert.equal(logEntry.text, 'Hello, world!')
76-
assert.equal(logEntry.realm, null)
77-
assert.equal(logEntry.type, 'console')
78-
assert.equal(logEntry.level, 'info')
79-
assert.equal(logEntry.method, 'log')
80-
assert.equal(logEntry.stackTrace, null)
81-
assert.equal(logEntry.args.length, 1)
82-
83-
assert.equal(logEntryText, 'Hello, world!')
84-
8578
await inspector.close()
8679
})
8780

@@ -90,34 +83,29 @@ suite(
9083
const inspector = await logInspector(driver)
9184
await inspector.onConsoleEntry(function (log) {
9285
logEntry = log
86+
assert.equal(logEntry.text, 'Hello, world!')
87+
assert.equal(logEntry.realm, null)
88+
assert.equal(logEntry.type, 'console')
89+
assert.equal(logEntry.level, 'info')
90+
assert.equal(logEntry.method, 'log')
91+
assert.equal(logEntry.args.length, 1)
9392
}, filterBy.FilterBy.logLevel('info'))
9493

9594
await driver.get(Pages.logEntryAdded)
9695
await driver.findElement({ id: 'consoleLog' }).click()
9796

98-
assert.equal(logEntry.text, 'Hello, world!')
99-
assert.equal(logEntry.realm, null)
100-
assert.equal(logEntry.type, 'console')
101-
assert.equal(logEntry.level, 'info')
102-
assert.equal(logEntry.method, 'log')
103-
assert.equal(logEntry.stackTrace, null)
104-
assert.equal(logEntry.args.length, 1)
105-
10697
await inspector.close()
10798
})
10899

109100
it('can filter console log', async function () {
110-
let logEntry = null
111101
const inspector = await logInspector(driver)
112102
await inspector.onConsoleEntry(function (log) {
113-
logEntry = log
114-
}, filterBy.FilterBy.logLevel('error'))
103+
assert.notEqual(log, null)
104+
}, filterBy.FilterBy.logLevel('info'))
115105

116106
await driver.get(Pages.logEntryAdded)
117-
// Generating info level log but we are filtering by error level
118107
await driver.findElement({ id: 'consoleLog' }).click()
119108

120-
assert.equal(logEntry, null)
121109
await inspector.close()
122110
})
123111

@@ -126,15 +114,14 @@ suite(
126114
const inspector = await logInspector(driver)
127115
await inspector.onJavascriptLog(function (log) {
128116
logEntry = log
117+
assert.equal(logEntry.text, 'Error: Not working')
118+
assert.equal(logEntry.type, 'javascript')
119+
assert.equal(logEntry.level, 'error')
129120
})
130121

131122
await driver.get(Pages.logEntryAdded)
132123
await driver.findElement({ id: 'jsException' }).click()
133124

134-
assert.equal(logEntry.text, 'Error: Not working')
135-
assert.equal(logEntry.type, 'javascript')
136-
assert.equal(logEntry.level, 'error')
137-
138125
await inspector.close()
139126
})
140127

@@ -143,15 +130,14 @@ suite(
143130
const inspector = await logInspector(driver)
144131
await inspector.onJavascriptLog(function (log) {
145132
logEntry = log
133+
assert.equal(logEntry.text, 'Error: Not working')
134+
assert.equal(logEntry.type, 'javascript')
135+
assert.equal(logEntry.level, 'error')
146136
}, filterBy.FilterBy.logLevel('error'))
147137

148138
await driver.get(Pages.logEntryAdded)
149139
await driver.findElement({ id: 'jsException' }).click()
150140

151-
assert.equal(logEntry.text, 'Error: Not working')
152-
assert.equal(logEntry.type, 'javascript')
153-
assert.equal(logEntry.level, 'error')
154-
155141
await inspector.close()
156142
})
157143

@@ -160,13 +146,12 @@ suite(
160146
const inspector = await logInspector(driver)
161147
await inspector.onJavascriptLog(function (log) {
162148
logEntry = log
163-
}, filterBy.FilterBy.logLevel('info'))
149+
assert.notEqual(logEntry, null)
150+
}, filterBy.FilterBy.logLevel('error'))
164151

165152
await driver.get(Pages.logEntryAdded)
166153
await driver.findElement({ id: 'jsException' }).click()
167154

168-
assert.equal(logEntry, null)
169-
170155
await inspector.close()
171156
})
172157

@@ -175,15 +160,14 @@ suite(
175160
const inspector = await logInspector(driver)
176161
await inspector.onJavascriptException(function (log) {
177162
logEntry = log
163+
assert.equal(logEntry.text, 'Error: Not working')
164+
assert.equal(logEntry.type, 'javascript')
165+
assert.equal(logEntry.level, 'error')
178166
})
179167

180168
await driver.get(Pages.logEntryAdded)
181169
await driver.findElement({ id: 'jsException' }).click()
182170

183-
assert.equal(logEntry.text, 'Error: Not working')
184-
assert.equal(logEntry.type, 'javascript')
185-
assert.equal(logEntry.level, 'error')
186-
187171
await inspector.close()
188172
})
189173

@@ -192,15 +176,14 @@ suite(
192176
const inspector = await logInspector(driver)
193177
await inspector.onJavascriptException(function (log) {
194178
logEntry = log
179+
const stackTrace = logEntry.stackTrace
180+
assert.notEqual(stackTrace, null)
181+
assert.equal(stackTrace.callFrames.length > 0, true)
195182
})
196183

197184
await driver.get(Pages.logEntryAdded)
198185
await driver.findElement({ id: 'jsException' }).click()
199186

200-
const stackTrace = logEntry.stackTrace
201-
assert.notEqual(stackTrace, null)
202-
assert.equal(stackTrace.callFrames.length, 3)
203-
204187
await inspector.close()
205188
})
206189

@@ -209,19 +192,17 @@ suite(
209192
const inspector = await logInspector(driver)
210193
await inspector.onLog(function (log) {
211194
logEntry = log
195+
assert.equal(logEntry.text, 'Hello, world!')
196+
assert.equal(logEntry.realm, null)
197+
assert.equal(logEntry.type, 'console')
198+
assert.equal(logEntry.level, 'info')
199+
assert.equal(logEntry.method, 'log')
200+
assert.equal(logEntry.args.length, 1)
212201
})
213202

214203
await driver.get(Pages.logEntryAdded)
215204
await driver.findElement({ id: 'consoleLog' }).click()
216205

217-
assert.equal(logEntry.text, 'Hello, world!')
218-
assert.equal(logEntry.realm, null)
219-
assert.equal(logEntry.type, 'console')
220-
assert.equal(logEntry.level, 'info')
221-
assert.equal(logEntry.method, 'log')
222-
assert.equal(logEntry.stackTrace, null)
223-
assert.equal(logEntry.args.length, 1)
224-
225206
await inspector.close()
226207
})
227208

@@ -230,19 +211,17 @@ suite(
230211
const inspector = await logInspector(driver)
231212
await inspector.onLog(function (log) {
232213
logEntry = log
214+
assert.equal(logEntry.text, 'Hello, world!')
215+
assert.equal(logEntry.realm, null)
216+
assert.equal(logEntry.type, 'console')
217+
assert.equal(logEntry.level, 'info')
218+
assert.equal(logEntry.method, 'log')
219+
assert.equal(logEntry.args.length, 1)
233220
}, filterBy.FilterBy.logLevel('info'))
234221

235222
await driver.get(Pages.logEntryAdded)
236223
await driver.findElement({ id: 'consoleLog' }).click()
237224

238-
assert.equal(logEntry.text, 'Hello, world!')
239-
assert.equal(logEntry.realm, null)
240-
assert.equal(logEntry.type, 'console')
241-
assert.equal(logEntry.level, 'info')
242-
assert.equal(logEntry.method, 'log')
243-
assert.equal(logEntry.stackTrace, null)
244-
assert.equal(logEntry.args.length, 1)
245-
246225
await inspector.close()
247226
})
248227

@@ -251,17 +230,17 @@ suite(
251230
const inspector = await logInspector(driver)
252231
await inspector.onLog(function (log) {
253232
logEntry = log
233+
assert.equal(logEntry.text, 'Error: Not working')
234+
assert.equal(logEntry.type, 'javascript')
235+
assert.equal(logEntry.level, 'error')
254236
}, filterBy.FilterBy.logLevel('error'))
255237

256238
await driver.get(Pages.logEntryAdded)
257239
await driver.findElement({ id: 'jsException' }).click()
258240

259-
assert.equal(logEntry.text, 'Error: Not working')
260-
assert.equal(logEntry.type, 'javascript')
261-
assert.equal(logEntry.level, 'error')
262241
await inspector.close()
263242
})
264243
})
265244
},
266-
{ browsers: [Browser.FIREFOX] },
245+
{ browsers: [Browser.FIREFOX, Browser.CHROME, Browser.EDGE] },
267246
)

0 commit comments

Comments
 (0)