Skip to content

Conversation

mweinelt
Copy link

@mweinelt mweinelt commented Oct 30, 2023

Fix test for CONDA_PREFIX in selenium manager, which regressed in 4.12.0.

Description

Accessing CONDA_PREFIX in os.environ fails with a KeyError when it is not set. The condition should instead check for the existence of the key, before accessing it in the following codepath.

Fixes: d4285d1 ("fix for conda install of selenium-manager (#12536)")

Motivation and Context

Traceback (most recent call last):
 File "/nix/store/jdm5chqkmh3z0wbip7r165fas3bfg1y4-python3-3.11.5-env/lib/python3.11/site-packages/selenium/webdriver/common/driver_finder.py", line 38, in get_path
   path = SeleniumManager().driver_location(options) if path is None else path
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/nix/store/jdm5chqkmh3z0wbip7r165fas3bfg1y4-python3-3.11.5-env/lib/python3.11/site-packages/selenium/webdriver/common/selenium_manager.py", line 78, in driver_location
   args = [str(self.get_binary()), "--browser", browser]
               ^^^^^^^^^^^^^^^^^
 File "/nix/store/jdm5chqkmh3z0wbip7r165fas3bfg1y4-python3-3.11.5-env/lib/python3.11/site-packages/selenium/webdriver/common/selenium_manager.py", line 57, in get_binary
   if not path.is_file() and os.environ["CONDA_PREFIX"]:
                             ~~~~~~~~~~^^^^^^^^^^^^^^^^
 File "<frozen os>", line 679, in __getitem__
KeyError: 'CONDA_PREFIX'

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Accessing CONDA_PREFIX in os.environ fails with a KeyError when it is
not set. The condition should instead check for the existence of the
key, before accessing it in the following codepath

Fixes: d4285d1 ("fix for conda install of selenium-manager (SeleniumHQ#12536)")
@CLAassistant
Copy link

CLAassistant commented Oct 30, 2023

CLA assistant check
All committers have signed the CLA.

@titusfortner
Copy link
Member

So this never actually worked?

I think the plan is to remove this functionality entirely now that people can set SE_MANAGER_PATH to point to the location of the selenium manager. Either the user can set it or the package manager can set it.

@titusfortner
Copy link
Member

Thank you for the PR.

Between this and #13076 it appears this was not working, so I'm removing it.

The correct fix now is for the location of the Selenium Manager binary to be specified in SE_MANAGER_PATH environment variable. Ideally this can be added by the anaconda project by default.

titusfortner added a commit that referenced this pull request Nov 1, 2023
Code did not work as desired #13071 & #13076 and a better solution now available
@mweinelt mweinelt deleted the py-selenium-manager-fix-conda-path-access branch November 1, 2023 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants