question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[🐛 Bug]: edge in SELENIUM_BROWSER environment variable leads to web driver not building due to error

See original GitHub issue

What 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:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
harsha509commented, Jan 8, 2022

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!

2reactions
harsha509commented, Jan 8, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to launch Edge browser through environmental variable
Hi,. I am not able to launch the Edge browser using the Environment variables. The error says,. "The path to the driver executable...
Read more >
How to solve "Webdriver cannot be resolved to a type" Error in ...
In this video it shows how one can resolve the " Webdriver cannot be resolved to a type" error while working with selenium...
Read more >
How to open up Microsoft Edge using Selenium and Python
Navigate to the Microsoft Edge Driver downloads page and download the driver that matches the Edge version number.
Read more >
How to fix common Selenium errors? - Ultimate QA
Selenium webdriver errors that are commonly faced by QA Engineers. ... Mac/Linux is not returning environment variable values from terminal.
Read more >
Changes - Selenium
Native support has been removed for Opera and PhantomJS as the WebDriver implementations for these browsers are no longer under active development. For...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found