Skip to content

Commit

Permalink
[js] Restore withCapabilities() to ensure backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
pujagani committed Sep 29, 2021
1 parent 5f1a0f8 commit 9a767b5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion javascript/node/selenium-webdriver/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class Builder {
}

/**
* @deprecated Since Selenium 4.0 withCapabilities is deprecated, use set*Options instead where * is the browser(eg setChromeOptions)
* Recommended way is to use set*Options where * is the browser(eg setChromeOptions)
*
* Sets the desired capabilities when requesting a new session. This will
* overwrite any previously set capabilities.
Expand Down
27 changes: 27 additions & 0 deletions javascript/node/selenium-webdriver/test/builder_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,30 @@ test.suite(function (env) {
})
}
})

describe('Builder', function () {
describe('catches incorrect use of browser options class', function () {
function test(key, options) {
it(key, async function () {
let builder = new Builder().withCapabilities(
new Capabilities()
.set('browserName', 'fake-browser-should-not-try-to-start')
.set(key, new options())
)
try {
let driver = await builder.build()
await driver.quit()
return Promise.reject(Error('should have failed'))
} catch (ex) {
if (!(ex instanceof error.InvalidArgumentError)) {
throw ex
}
}
})
}

test('chromeOptions', chrome.Options)
test('moz:firefoxOptions', firefox.Options)
test('safari.options', safari.Options)
})
})

0 comments on commit 9a767b5

Please sign in to comment.