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]: Selenium manager not found via Anaconda distribution #11234

Closed
Fradhyle opened this issue Nov 8, 2022 · 25 comments · Fixed by #12536
Closed

[🐛 Bug]: Selenium manager not found via Anaconda distribution #11234

Fradhyle opened this issue Nov 8, 2022 · 25 comments · Fixed by #12536
Assignees
Milestone

Comments

@Fradhyle
Copy link

Fradhyle commented Nov 8, 2022

What happened?

I tried to test new Selenium manager feature with Python 3.9.13 and Edge 107.0.1418.35 (Stable) (64bit), but the exception occurs.

The code I tried

from selenium import webdriver
driver = webdriver.Edge()

and the message is this
WebDriverException: Message: 'msedgedriver' executable needs to be in PATH. Please download from https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

If I enter msedge on the 'Run' window, Edge browser opens normally.

How can we reproduce the issue?

from selenium import webdriver
driver = webdriver.Edge()

Relevant log output

WebDriverException                        Traceback (most recent call last)
C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\common\service.py in start(self)
     96                 try:
---> 97                     path = SeleniumManager.driver_location(browser)
     98                 except WebDriverException as new_err:

C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\common\selenium_manager.py in driver_location(browser)
     66
---> 67         args = (str(SeleniumManager.get_binary()), "--browser", browser)
     68         result = SeleniumManager.run(args)

C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\common\selenium_manager.py in get_binary()
     51         if not path.is_file():
---> 52             raise WebDriverException("Unable to obtain Selenium Manager")
     53

WebDriverException: Message: Unable to obtain Selenium Manager


During handling of the above exception, another exception occurred:

WebDriverException                        Traceback (most recent call last)
<ipython-input-2-9e8e880ac5d1> in <cell line: 1>()
----> 1 driver = webdriver.Edge()

C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\edge\webdriver.py in __init__(self, executable_path, port, options, service_args, capabilities, service_log_path, service, keep_alive, verbose)
     71             service = Service(executable_path, port, service_args, service_log_path)
     72
---> 73         super().__init__(
     74             DesiredCapabilities.EDGE["browserName"],
     75             "ms",

C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\chromium\webdriver.py in __init__(self, browser_name, vendor_prefix, port, options, service_args, desired_capabilities, service_log_path, service, keep_alive)
    101
    102         self.service = service
--> 103         self.service.start()
    104
    105         try:

C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\common\service.py in start(self)
     98                 except WebDriverException as new_err:
     99                     logger.debug("Unable to obtain driver using Selenium Manager: " + new_err.msg)
--> 100                     raise err
    101
    102                 self._start_process(path)

C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\common\service.py in start(self)
     89         """
     90         try:
---> 91             self._start_process(self.path)
     92         except WebDriverException as err:
     93             if "executable needs to be in PATH" in err.msg:

C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\common\service.py in _start_process(self, path)
    201         except OSError as err:
    202             if err.errno == errno.ENOENT:
--> 203                 raise WebDriverException(
    204                     f"'{os.path.basename(self.path)}' executable needs to be in PATH. {self.start_error_message}"
    205                 )

WebDriverException: Message: 'msedgedriver' executable needs to be in PATH. Please download from https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

Operating System

Windows 10 Enterprise 22H2

Selenium version

Python 4.6.0

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

Edge 107.0.1418.35 (Stable) (64bit)

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

Selenium Manager

Are you using Selenium Grid?

No response

@Fradhyle Fradhyle changed the title [🐛 Bug]: Selenium for Python 4.6.0 [🐛 Bug]: Selenium for Python 4.6.0 unable to obtain Selenium manager Nov 8, 2022
@github-actions
Copy link

github-actions bot commented Nov 8, 2022

@Sweetbarrow, 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!

@titusfortner
Copy link
Member

Hmm, it's failing on conditional if not path.is_file(). Which is coming from:

Path(__file__).parent.joinpath(directory, file)

On my mac this is: /Users/titusfortner/code/seleniumhq.github.io/examples/python/venv/lib/python3.9/site-packages/selenium/webdriver/common/macos/selenium-manager

  1. We should add the path to the error message so it can be investigated.
  2. @symonk maybe the way I'm setting the directory doesn't work for all the weird ways people use Python?

@symonk
Copy link
Member

symonk commented Nov 8, 2022

@Sweetbarrow can you drop the output of this in your script:

import sys
print(sys.executable)

As a side note; we should list the files in the path etc to debug better in future. Once you have the interpreter path above can you check the file system on disk inside its lib/python.x/site-packages/* to find the directories inside selenium/webdriver/common/* for the platform

@Fradhyle
Copy link
Author

Fradhyle commented Nov 8, 2022

Hi, @symonk
This is the output you requested.

C:\ProgramData\Anaconda3\python.exe

Plus, I can see selenium_manager.py inside C:\ProgramData\Anaconda3\Lib\site-packages\selenium\webdriver\common
By the way, I tried same code on Windows 11 22H2, Edge 107.0.1418.35 (Stable) (64 bit), Python 3.9.13 and the same error has raised.

@symonk
Copy link
Member

symonk commented Nov 8, 2022

I will get access to a windows machine and use anaconda to test it out thanks! I suspect its to do with that explicitly; as a work around you could manually put the edge driver on your path for now. Thanks for the report.

@Sweetbarrow is there a /common/windows/selenium-manager.exe file in there?

@Fradhyle
Copy link
Author

Fradhyle commented Nov 8, 2022

@symonk No.
I thought it's included in the code like webdriver_manager by Sergey Pirogov, isn't it?

@Fradhyle
Copy link
Author

Fradhyle commented Nov 8, 2022

@symonk I just downloaded seperate executable from Github and it works well now.
As I just said, I thought it works like webdriver_manager and didn't think it requires seperate executable.

@titusfortner
Copy link
Member

there is a separate selenium manager executable that is distributed and it is what is figuring out which driver to get.

@Fradhyle
Copy link
Author

Fradhyle commented Nov 8, 2022

@titusfortner Thank you for your answer.
It was my mistake.

@Fradhyle Fradhyle closed this as completed Nov 8, 2022
@symonk
Copy link
Member

symonk commented Nov 8, 2022

this should be working by default @titusfortner no? I don't think we should close it. (without requiring additional manual installs; pip install should suffice?)

@Fradhyle Fradhyle reopened this Nov 8, 2022
@Fradhyle
Copy link
Author

Fradhyle commented Nov 8, 2022

As user of Selenium, I hope Selenium manager included when get package from package manager.
I don't know how webdriver_manager works exactly, but the phrase 'batteries included' from Selenium blog article makes me confused.
That's why I thought it was a bug.

@titusfortner
Copy link
Member

Sorry. I was unclear.

There are 3 selenium-manager executables (one for each of the 3 major OS's) that are bundled with the various selenium packages, including inside the whl file.

Selenium 4.6 in Python should include a selenium\common\windows\selenium-manager.exe file.

For some reason on your machine, it appears that it is not getting found. I know relative file path is trickier in Python than the other languages for *reasons, so it's probably a bug in how it is getting referenced. It might be related to anaconda. We should have had the path it looking for in the error message so we could more easily figure out where it is looking instead of where it should be looking.

@Fradhyle
Copy link
Author

Fradhyle commented Nov 8, 2022

@titusfortner Oh...
Thank you for the answer.
I'll look forward to be fixed in the future release.
For your information, I installed Selenium 4.6.0 by execute conda update --all -c conda-forge from Anaconda Powershell Prompt run as Administrator because I was using previous release of Selenium.

@titusfortner titusfortner changed the title [🐛 Bug]: Selenium for Python 4.6.0 unable to obtain Selenium manager [🐛 Bug]: Selenium manager not found via Anaconda distribution Nov 8, 2022
@symonk
Copy link
Member

symonk commented Nov 9, 2022

the version shipped by conda does in fact not ship with the manager directory; I assume conda maybe tries to use a source distribution with setuptools directly? and we don't use that ourselves unfortunately. Assume they are cloning and relying on setup.cfg/setup.py which is completely normal in the python world for most packages, as for a solution - I'm not quite sure as we rely on bazel to do things and don't support the normal python build backend machinery right now.

@titusfortner
Copy link
Member

My question is what are we doing differently with devtools that we aren't doing for Selenium-Manager?

@symonk
Copy link
Member

symonk commented Nov 11, 2022

@titusfortner possibly this but I haven't a clue how bazel operates really

@AutomatedTester
Copy link
Member

AutomatedTester commented Nov 11, 2022 via email

@titusfortner titusfortner added this to the 4.7 milestone Nov 17, 2022
@titusfortner
Copy link
Member

Fixed in #11329

@github-actions
Copy link

github-actions bot commented Jan 1, 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.

@titusfortner
Copy link
Member

Did I close this incorrectly? I can't tell if there was a fix and I linked the wrong thing to close this, or if this wasn't actually fixed. We have a new report (#11980) that it is still not working.
@symonk can you verify?

@titusfortner titusfortner reopened this May 2, 2023
@SeleniumHQ SeleniumHQ unlocked this conversation May 9, 2023
@titusfortner
Copy link
Member

@KittyMurphy in response to your question on the other thread...

Selenium Manager only works with what is bundled in the bindings.

But if you have the latest Selenium Manager built on your machine, try:

./selenium-manager --browser chrome --browser-path /location/to/anaconda/chrome --debug

@KittyMurphy
Copy link

@titusfortner I don't have Selenium Manager as it seems to be missing in the conda distribution. For those that are experiencing this issue, I did a pip install instead and now everything seems to be working fine.

@titusfortner
Copy link
Member

Oh, right, the issue isn't like snap where the driver is special, the issue is that it doesn't actually show up with Selenium.

@stevetracvc
Copy link
Contributor

I found a workaround. Conda has a separate library, selenium-manager, that is installed in the environment's bin folder. I'll submit a PR in a few minutes

stevetracvc added a commit to stevetracvc/selenium that referenced this issue Aug 11, 2023
conda doesn't seem to properly package selenium-manager, so it needs
to be install as a separate package (via conda). But this puts it in
the environment's bin folder.

This commit checks the path for the selenium-manager executable if
it isn't installed in the package's webdriver/common/<platform>/
folder.

fixes SeleniumHQ#11234 and SeleniumHQ#12084
@titusfortner titusfortner modified the milestones: 4.7, 4.12 Aug 14, 2023
stevetracvc added a commit to stevetracvc/selenium that referenced this issue Aug 14, 2023
conda doesn't seem to properly package selenium-manager, so it needs
to be install as a separate package (via conda). But this puts it in
the environment's bin folder.

This commit checks the path for the selenium-manager executable if
it isn't installed in the package's webdriver/common/<platform>/
folder.

fixes SeleniumHQ#11234 and SeleniumHQ#12084
titusfortner pushed a commit that referenced this issue Aug 15, 2023
* fix for conda install of selenium-manager

conda doesn't seem to properly package selenium-manager, so it needs
to be install as a separate package (via conda). But this puts it in
the environment's bin folder.

This commit checks the path for the selenium-manager executable if
it isn't installed in the package's webdriver/common/<platform>/
folder.

fixes #11234 and #12084

* fix linting error

* use conda bin folder, rather than searching PATH

* fix for tox/linting error
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants