Skip to content

Commit 9a767b5

Browse files
committed
[js] Restore withCapabilities() to ensure backward compatibility
1 parent 5f1a0f8 commit 9a767b5

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

javascript/node/selenium-webdriver/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ class Builder {
318318
}
319319

320320
/**
321-
* @deprecated Since Selenium 4.0 withCapabilities is deprecated, use set*Options instead where * is the browser(eg setChromeOptions)
321+
* Recommended way is to use set*Options where * is the browser(eg setChromeOptions)
322322
*
323323
* Sets the desired capabilities when requesting a new session. This will
324324
* overwrite any previously set capabilities.

javascript/node/selenium-webdriver/test/builder_test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,30 @@ test.suite(function (env) {
6969
})
7070
}
7171
})
72+
73+
describe('Builder', function () {
74+
describe('catches incorrect use of browser options class', function () {
75+
function test(key, options) {
76+
it(key, async function () {
77+
let builder = new Builder().withCapabilities(
78+
new Capabilities()
79+
.set('browserName', 'fake-browser-should-not-try-to-start')
80+
.set(key, new options())
81+
)
82+
try {
83+
let driver = await builder.build()
84+
await driver.quit()
85+
return Promise.reject(Error('should have failed'))
86+
} catch (ex) {
87+
if (!(ex instanceof error.InvalidArgumentError)) {
88+
throw ex
89+
}
90+
}
91+
})
92+
}
93+
94+
test('chromeOptions', chrome.Options)
95+
test('moz:firefoxOptions', firefox.Options)
96+
test('safari.options', safari.Options)
97+
})
98+
})

0 commit comments

Comments
 (0)