[🐛 Bug]: edge in SELENIUM_BROWSER environment variable leads to web driver not building due to error
See original GitHub issueWhat happened?
I set up the environment variable SELENIUM_BROWSER
, which includes the names of the browsers I want to run tests against. The values I use are the Browser names enumerated here. As far as I was experiencing, adding multiple browser names and seperating them by comma works fine. So, if I run tests against Firefox, Chrome and Opera, the value of the environment variable SELENIUM_BROWSER
is firefox,chrome,opera
. That works fine. However, as soon as I add edge
to the environment variable, an error occurs as the web driver wasn’t successfully built when trying to run the tests in Microsoft Edge. I also tried entering different names, such as MicrosoftEdge
or msedge
, but with no success.
However, when using an older selenium-webdriver version (4.0.0−beta.3
), all tests run through.
Thank you in advance for looking into this. I couldn’t figure out the source of the problem myself.
How can we reproduce the issue?
// I modified file google_search_test.js to this:
const { Browser, By, Key, until } = require('..')
const { ignore, suite } = require('../testing')
suite(function (env) {
describe('Google Search', function () {
let driver
before(async function () {
// env.builder() returns a Builder instance preconfigured for the
// envrionment's target browser (you may still define browser specific
// options if necessary (i.e. firefox.Options or chrome.Options)).
driver = await env.builder()
// When you call Builder#build(), all options irrelevant to the selected browser are dropped
.setChromeOptions({acceptInsecureCerts: true})
.setOperaOptions({acceptInsecureCerts: true})
.setFirefoxOptions({acceptInsecureCerts: true})
.setEdgeOptions({acceptInsecureCerts: true})
.build()
await driver.getCapabilities().then((caps) => console.log('caps', caps));
})
it('demo', async function () {
await driver.get('https://www.google.com/ncr')
})
after(() => driver && driver.quit())
})
})
Relevant log output
> node node_modules/mocha/bin/mocha -t 10000 node_modules/selenium-webdriver/example/google_search_test.js
[INFO] Running tests against [firefox, chrome, opera, MicrosoftEdge]
[firefox]
Google Search
√ demo (1520ms)
[chrome]
Google Search
√ demo (1405ms)
[opera]
Google Search
√ demo (585ms)
[MicrosoftEdge]
Google Search
1) "before all" hook for "demo"
3 passing (10s)
1 failing
1) [MicrosoftEdge]
Google Search
"before all" hook for "demo":
TypeError: Cannot read properties of undefined (reading 'apply')
at Builder.builder.build (node_modules\selenium-webdriver\testing\index.js:291:59)
at Context.<anonymous> (node_modules\selenium-webdriver\example\google_search_test.js:18:10)
at processImmediate (node:internal/timers:464:21)
Operating System
Windows 10
Some more information about node, npm and mocha:
node -v v16.13.1
npm -v 8.1.2
mocha (version 9.1.3)
Selenium version
4.1.0
What are the browser(s) and version(s) where you see this issue?
Microsoft Edge Version 96.0.1054.62 (Offizielles Build) (64-Bit)
What are the browser driver(s) and version(s) where you see this issue?
Version: 96.0.1054.62
Are you using Selenium Grid?
No
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (2 by maintainers)
Top GitHub Comments
Hi @naninuneno ,
Am not sure about IE as I am on mac machine. But looking into the code, yes it is also vulnerable to the same.
Will test and will provide fix when time permits!
Hi @naninuneno,
looking into code I see that. it because for edge
Capabilities[browser.name]
calls[Function: MicrosoftEdge]
but we have[Function: edge]
in here so it is returning undefined.to make it work you can change in here replace
[Function: edge]
to[Function: MicrosoftEdge]
I’ll push the fix once all tests gets passed. Fix will be available in next release!
Thanks, Sri Harsha