From 8a9414c140456604189930cc5fd6f6716fa9d4ef Mon Sep 17 00:00:00 2001 From: Andrei Solntsev Date: Thu, 2 Apr 2026 20:20:25 +0300 Subject: [PATCH 1/2] fix failing test "can unpin script" in "webdriver_script_test.js" it seems that FireFox can call pinned JS script two or three times. In this test, the exact count is not important - it's enough to verify that the script was called at least once. --- .../test/lib/webdriver_script_test.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/javascript/selenium-webdriver/test/lib/webdriver_script_test.js b/javascript/selenium-webdriver/test/lib/webdriver_script_test.js index 6cb0f18664bf2..a7c9912cea8d8 100644 --- a/javascript/selenium-webdriver/test/lib/webdriver_script_test.js +++ b/javascript/selenium-webdriver/test/lib/webdriver_script_test.js @@ -139,20 +139,24 @@ suite( }) it('can unpin script', async function () { - const id = await driver.script().pin("() => { console.log('Hello!'); }") + const id = await driver.script().pin("() => { console.log('Hello'); }") + await driver.script().pin("() => { console.log('World'); }") - let count = 0 + const logs = [] await driver.script().addConsoleMessageHandler((logEntry) => { - count++ + logs.push(logEntry.text) }) await driver.get(Pages.logEntryAdded) + assert.ok(logs.includes('Hello'), `[${logs}] should contain "Hello"`) + assert.ok(logs.includes('World'), `[${logs}] should contain "World"`) await driver.script().unpin(id) + logs.length = 0 await driver.get(Pages.logEntryAdded) - - assert.equal(count, 1) + assert.ok(logs.includes('World'), `[${logs}] should contain "World"`) + assert.ok(!logs.includes('Hello'), `[${logs}] should not contain "Hello"`) }) }) }, From c83ae06a96f88ad38d22bb584e5dd84ed36b17cb Mon Sep 17 00:00:00 2001 From: Andrei Solntsev Date: Thu, 2 Apr 2026 20:21:24 +0300 Subject: [PATCH 2/2] remove unneeded delays in "webdriver_script_test.js" it seems that we don't need to wait: the usual "await driver.get(...)" already does it. --- .../test/lib/webdriver_script_test.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/javascript/selenium-webdriver/test/lib/webdriver_script_test.js b/javascript/selenium-webdriver/test/lib/webdriver_script_test.js index a7c9912cea8d8..f1e4c632f1ad1 100644 --- a/javascript/selenium-webdriver/test/lib/webdriver_script_test.js +++ b/javascript/selenium-webdriver/test/lib/webdriver_script_test.js @@ -35,10 +35,6 @@ suite( await driver.quit() }) - function delay(ms) { - return new Promise((resolve) => setTimeout(resolve, ms)) - } - describe('script()', function () { it('can listen to console log', async function () { let log = null @@ -49,8 +45,6 @@ suite( await driver.get(Pages.logEntryAdded) await driver.findElement({ id: 'consoleLog' }).click() - await delay(3000) - assert.equal(log.text, 'Hello, world!') assert.equal(log.realm, null) assert.equal(log.type, 'console') @@ -69,8 +63,6 @@ suite( await driver.get(Pages.logEntryAdded) await driver.findElement({ id: 'jsException' }).click() - await delay(3000) - assert.equal(log.text, 'Error: Not working') assert.equal(log.type, 'javascript') assert.equal(log.level, 'error') @@ -133,8 +125,6 @@ suite( await driver.get(Pages.logEntryAdded) - await delay(3000) - assert.equal(log.text, 'Hello!') })