Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛 Bug]: msedge webdriver launches chrome on Ubuntu linux when specify the webdriver path #12518

Closed
fz0000 opened this issue Aug 8, 2023 · 13 comments
Labels
G-msedgedriver Requires fixes in MSEdgeDriver I-defect needs-triaging

Comments

@fz0000
Copy link

fz0000 commented Aug 8, 2023

What happened?

I have installed both Google Chrome and Microsoft Edge on Ubuntu.
Default setting(i.e. webdriver.Edge() without params) works correctly.

But when I use a specific webdriver path, Chrome is launched unexpectedly.

So I have to specify the msedge binary location too, as a workaround:

options = webdriver.EdgeOptions()
options.binary_location = '/usr/bin/microsoft-edge'

btw, this issue does NOT occur on Windows.

How can we reproduce the issue?

from selenium import webdriver
from selenium.webdriver.edge.service import Service

executable_path = '/my_path_to/msedgedriver'
service = Service(executable_path=executable_path)
driver = webdriver.Edge(service=service)
driver.quit()

Relevant log output

Traceback (most recent call last):
  File "/my/test.py", line 6, in <module>
    driver = webdriver.Edge(service=service)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/my/venv/lib/python3.11/site-packages/selenium/webdriver/edge/webdriver.py", line 45, in __init__
    super().__init__(
  File "/my/venv/lib/python3.11/site-packages/selenium/webdriver/chromium/webdriver.py", line 56, in __init__
    super().__init__(
  File "/my/venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 206, in __init__
    self.start_session(capabilities)
  File "/my/venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 290, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/my/venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 345, in execute
    self.error_handler.check_response(response)
  File "/my/venv/lib/python3.11/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: unrecognized Microsoft Edge version: Chrome/115.0.5790.170
Stacktrace:
#0 0x5570193204e3 <unknown>
#1 0x557019025981 <unknown>
#2 0x557018ffa9bf <unknown>
#3 0x557018ffa17f <unknown>
#4 0x5570190128a2 <unknown>
#5 0x557019056d2a <unknown>
#6 0x5570190531ef <unknown>
#7 0x55701904ef9c <unknown>
#8 0x557019091455 <unknown>
#9 0x557019088603 <unknown>
#10 0x55701905aa11 <unknown>
#11 0x55701905bc2e <unknown>
#12 0x5570192eca26 <unknown>
#13 0x5570192f0389 <unknown>
#14 0x5570192efe79 <unknown>
#15 0x5570192f0845 <unknown>
#16 0x5570192f7cab <unknown>
#17 0x5570192f0bee <unknown>
#18 0x5570192cb7a1 <unknown>
#19 0x55701930bf38 <unknown>
#20 0x55701930c074 <unknown>
#21 0x557019319786 <unknown>
#22 0x7f9c7b28f18a <unknown>

Operating System

Ubuntu 23.04

Selenium version

4.11.2

What are the browser(s) and version(s) where you see this issue?

Edge 115.0.1901.200

What are the browser driver(s) and version(s) where you see this issue?

Microsoft Edge WebDriver 115.0.1901.200 (64b0164e9f6a43a530acd52f6525ddd6fe990817)

Are you using Selenium Grid?

No response

@github-actions
Copy link

github-actions bot commented Aug 8, 2023

@fz0000, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@diemol
Copy link
Member

diemol commented Aug 8, 2023

What happens when you run on the terminal /usr/bin/microsoft-edge? What is the output?

@diemol
Copy link
Member

diemol commented Aug 8, 2023

Sorry, I meant, what happens when you run '/my_path_to/msedgedriver'?

@titusfortner
Copy link
Member

titusfortner commented Aug 8, 2023

If you turn on logging and run it, we can get more insight — https://www.selenium.dev/documentation/webdriver/troubleshooting/logging/

If you have a driver on PATH and don't specify anything, Selenium will first locate the Edge Browser then will take the driver it finds on PATH and tell it to use the browser it found.

If you specify the browser location, Selenium will use the provided browser and take the driver it finds on PATH. The behavior should be exactly the same if the location provided matches the location Selenium finds by default.

@diemol
Copy link
Member

diemol commented Aug 8, 2023

I wonder if it is actually a ChromeDriver renamed to MSEdgeDriver by accident. I do not see how else a MSEdgeDriver binary can open Chrome.

@titusfortner
Copy link
Member

titusfortner commented Aug 8, 2023

Yes, this is the error you would get for a chromedriver trying to open Edge, but that doesn't track with how the issue has been reported, so I'm interested in seeing logs.

@fz0000
Copy link
Author

fz0000 commented Aug 9, 2023

I have checked again and the webdriver is correct.

The webdriver log with default settings is:

Selenium Manager binary found at: /my/venv/lib/python3.11/site-packages/selenium/webdriver/common/linux/selenium-manager
Executing process: /my/venv/lib/python3.11/site-packages/selenium/webdriver/common/linux/selenium-manager --browser MicrosoftEdge --debug --output json
Checking msedgedriver in PATH
Running command: msedgedriver --version
Output: ""
msedgedriver not found in PATH
edge detected at /opt/microsoft/msedge/microsoft-edge
Using shell command to find out edge version
Running command: /opt/microsoft/msedge/microsoft-edge --version
Output: "Microsoft Edge 115.0.1901.200 "
Detected browser: edge 115.0.1901.200
Reading msedgedriver version from https://msedgedriver.azureedge.net/LATEST_RELEASE_115_LINUX
Required driver: msedgedriver 115.0.1901.200
Driver URL: https://msedgedriver.azureedge.net/115.0.1901.200/edgedriver_linux64.zip
Driver path: /home/user/.cache/selenium/msedgedriver/linux64/115.0.1901.200/msedgedriver
Browser path: /opt/microsoft/msedge/microsoft-edge
Using driver at: /home/user/.cache/selenium/msedgedriver/linux64/115.0.1901.200/msedgedriver
Started executable: `/home/user/.cache/selenium/msedgedriver/linux64/115.0.1901.200/msedgedriver` in a child process with pid: 1664229
Starting Microsoft Edge WebDriver 115.0.1901.200 (64b0164e9f6a43a530acd52f6525ddd6fe990817) on port 54831
To submit feedback, report a bug, or suggest new features, please visit https://github.com/MicrosoftEdge/EdgeWebDriver

Only local connections are allowed.
Please see https://aka.ms/WebDriverSecurity for suggestions on keeping Microsoft Edge WebDriver safe.

Microsoft Edge WebDriver was started successfully.

And if I specify the webdriver path, the webdriver log is:

Started executable: `/my_path_to/msedgedriver` in a child process with pid: 1665688
Starting Microsoft Edge WebDriver 115.0.1901.200 (64b0164e9f6a43a530acd52f6525ddd6fe990817) on port 45075
To submit feedback, report a bug, or suggest new features, please visit https://github.com/MicrosoftEdge/EdgeWebDriver

Only local connections are allowed.
Please see https://aka.ms/WebDriverSecurity for suggestions on keeping Microsoft Edge WebDriver safe.

Microsoft Edge WebDriver was started successfully.

There seems no errors during launching the msedgedriver. Maybe something happened when the msedgedriver launches the edge browser. How could I get the detailed info?

@titusfortner
Copy link
Member

Here's how you get the driver logs for Edge - https://www.selenium.dev/documentation/webdriver/browsers/edge/#service

@fz0000
Copy link
Author

fz0000 commented Aug 10, 2023

I set the msedgedriver log level to ALL.

from selenium import webdriver
from selenium.webdriver.edge.service import Service

executable_path = '/my_path_to/msedgedriver'
service = Service(executable_path=executable_path, log_path='my.log', service_args=['--log-level=ALL', '--readable-timestamp'])
driver = webdriver.Edge(service=service)
driver.quit()

It's strange that the msedgedriver indeed launches /usr/bin/google-chrome, even if I set Edge as the default browser.

[08-10-2023 16:12:03.238302][INFO]: Starting Microsoft Edge WebDriver 115.0.1901.200 (64b0164e9f6a43a530acd52f6525ddd6fe990817) on port 58289
[08-10-2023 16:12:03.238487][INFO]: Please see https://aka.ms/WebDriverSecurity for suggestions on keeping Microsoft Edge WebDriver safe.
[08-10-2023 16:12:03.740966][INFO]: [5806e954c2b3f9bd2aa98aa7428912ff] COMMAND InitSession {
   "capabilities": {
      "alwaysMatch": {
         "browserName": "MicrosoftEdge",
         "ms:edgeOptions": {
            "args": [  ],
            "extensions": [  ]
         },
         "pageLoadStrategy": "normal"
      },
      "firstMatch": [ {
      } ]
   }
}
[08-10-2023 16:12:03.742252][INFO]: Populating Preferences file: {
   "alternate_error_pages": {
      "enabled": false
   },
   "autofill": {
      "enabled": false
   },
   "browser": {
      "check_default_browser": false
   },
   "distribution": {
      "import_bookmarks": false,
      "import_history": false,
      "import_search_engine": false,
      "make_chrome_default_for_user": false,
      "skip_first_run_ui": true
   },
   "dns_prefetching": {
      "enabled": false
   },
   "profile": {
      "content_settings": {
         "pattern_pairs": {
            "https://*,*": {
               "media-stream": {
                  "audio": "Default",
                  "video": "Default"
               }
            }
         }
      },
      "default_content_setting_values": {
         "geolocation": 1
      },
      "default_content_settings": {
         "geolocation": 1,
         "mouselock": 1,
         "notifications": 1,
         "popups": 1,
         "ppapi-broker": 1
      },
      "password_manager_enabled": false
   },
   "safebrowsing": {
      "enabled": false
   },
   "search": {
      "suggest_enabled": false
   },
   "translate": {
      "enabled": false
   }
}
[08-10-2023 16:12:03.742444][INFO]: Populating Local State file: {
   "background_mode": {
      "enabled": false
   },
   "ssl": {
      "rev_checking": {
         "enabled": false
      }
   }
}
[08-10-2023 16:12:03.742782][INFO]: Launching Microsoft Edge: /usr/bin/google-chrome --allow-pre-commit-input --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-logging --log-level=0 --no-first-run --no-service-autorun --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.com.microsoft.Edge.rW5F82 data:,

DevTools listening on ws://127.0.0.1:43721/devtools/browser/4b87fbc3-fd98-4f49-a9ed-a98a30f59d50
[08-10-2023 16:12:03.898148][DEBUG]: DevTools HTTP Request: http://localhost:43721/json/version
[08-10-2023 16:12:03.945883][DEBUG]: DevTools HTTP Response: {
   "Browser": "Chrome/115.0.5790.170",
   "Protocol-Version": "1.3",
   "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
   "V8-Version": "11.5.150.22",
   "WebKit-Version": "537.36 (@cc0d30c2ca5577520c8646671513241faa0bc105)",
   "webSocketDebuggerUrl": "ws://localhost:43721/devtools/browser/4b87fbc3-fd98-4f49-a9ed-a98a30f59d50"
}

......

[08-10-2023 16:13:03.687914][DEBUG]: DevTools HTTP Request: http://localhost:43721/json/version
[08-10-2023 16:13:03.692351][DEBUG]: DevTools HTTP Response: {
   "Browser": "Chrome/115.0.5790.170",
   "Protocol-Version": "1.3",
   "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
   "V8-Version": "11.5.150.22",
   "WebKit-Version": "537.36 (@cc0d30c2ca5577520c8646671513241faa0bc105)",
   "webSocketDebuggerUrl": "ws://localhost:43721/devtools/browser/4b87fbc3-fd98-4f49-a9ed-a98a30f59d50"
}

[08-10-2023 16:13:03.747474][INFO]: Failed to connect to msedge. Attempting to kill it.
[08-10-2023 16:13:03.777294][INFO]: [5806e954c2b3f9bd2aa98aa7428912ff] RESPONSE InitSession ERROR unknown error: unrecognized Microsoft Edge version: Chrome/115.0.5790.170
[08-10-2023 16:13:03.777327][DEBUG]: Log type 'driver' lost 0 entries on destruction
[08-10-2023 16:13:03.777336][DEBUG]: Log type 'browser' lost 0 entries on destruction

Is any one able to reproduce this issue?
And I will try later with newer versions.

@titusfortner
Copy link
Member

A few things...
This looks like a msedgedriver bug and should be reported to Microsoft:

[08-10-2023 16:12:03.742782][INFO]: Launching Microsoft Edge: /usr/bin/google-chrome

But also, Selenium 4.11 should not be affected by this bug! Selenium locates the correct browser, gets the right driver, then passes the location of the browser to the driver. Since your logs aren't showing that, something isn't right in your setup. Update to Selenium 4.11 and remove existing drivers from your system and it should do what you expect.

@titusfortner titusfortner added the G-msedgedriver Requires fixes in MSEdgeDriver label Aug 10, 2023
@github-actions
Copy link

Hi, @fz0000.
This issue has been determined to require fixes in MSEdgeDriver
or in the IE Mode in Edge.

You can see if the feature is passing in the Web Platform Tests.

If it is something new, please create an Issue with the MSEdgeDriver team.

Feel free to comment the issues that you raise back in this issue. Thank you.

@fz0000
Copy link
Author

fz0000 commented Aug 10, 2023

Yes, a similar issue has been tracked in MSEdgeDriver team recently, if anyone meets the same issue, please refer to MicrosoftEdge/EdgeWebDriver#102 for details. Thanks everyone.

Copy link

github-actions bot commented Dec 8, 2023

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
G-msedgedriver Requires fixes in MSEdgeDriver I-defect needs-triaging
Projects
None yet
Development

No branches or pull requests

3 participants