Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Selenium 4.3.0 has deprecated find_element_by*() methods #104

Closed
firasm opened this issue Jun 28, 2022 · 7 comments
Closed

Selenium 4.3.0 has deprecated find_element_by*() methods #104

firasm opened this issue Jun 28, 2022 · 7 comments

Comments

@firasm
Copy link

firasm commented Jun 28, 2022

Hi,

Just filing this issue - doing

chart.save() results in this error:

File "scripts/visualize_questions.py", line 61, in <module>
[11](https://github.com/open-resources/physics_bank/runs/7099958015?check_suite_focus=true#step:6:12)
    chart.save('images/topics.png',webdriver='firefox',scale_factor=2)
[12](https://github.com/open-resources/physics_bank/runs/7099958015?check_suite_focus=true#step:6:13)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/altair/vegalite/v4/api.py", line 488, in save
[13](https://github.com/open-resources/physics_bank/runs/7099958015?check_suite_focus=true#step:6:14)
    result = save(**kwds)
[14](https://github.com/open-resources/physics_bank/runs/7099958015?check_suite_focus=true#step:6:15)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/altair/utils/save.py", line 116, in save
[15](https://github.com/open-resources/physics_bank/runs/7099958015?check_suite_focus=true#step:6:16)
    mimebundle = spec_to_mimebundle(
[16](https://github.com/open-resources/physics_bank/runs/7099958015?check_suite_focus=true#step:6:17)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/altair/utils/mimebundle.py", line 60, in spec_to_mimebundle
[17](https://github.com/open-resources/physics_bank/runs/7099958015?check_suite_focus=true#step:6:18)
    return altair_saver.render(spec, format, mode=mode, **kwargs)
[18](https://github.com/open-resources/physics_bank/runs/7099958015?check_suite_focus=true#step:6:19)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/altair_saver/_core.py", line 257, in render
[19](https://github.com/open-resources/physics_bank/runs/7099958015?check_suite_focus=true#step:6:20)
    mimebundle.update(saver.mimebundle(fmt))
[20](https://github.com/open-resources/physics_bank/runs/7099958015?check_suite_focus=true#step:6:21)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/altair_saver/savers/_saver.py", line 90, in mimebundle
[21](https://github.com/open-resources/physics_bank/runs/7099958015?check_suite_focus=true#step:6:22)
    bundle[mimetype] = self._serialize(fmt, "mimebundle")
[22](https://github.com/open-resources/physics_bank/runs/7099958015?check_suite_focus=true#step:6:23)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/altair_saver/savers/_selenium.py", line 284, in _serialize
[23](https://github.com/open-resources/physics_bank/runs/7099958015?check_suite_focus=true#step:6:24)
    out = self._extract(fmt)
[24](https://github.com/open-resources/physics_bank/runs/7099958015?check_suite_focus=true#step:6:25)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/altair_saver/savers/_selenium.py", line 267, in _extract
[25](https://github.com/open-resources/physics_bank/runs/7099958015?check_suite_focus=true#step:6:26)
    driver.find_element_by_id("vis")
[26](https://github.com/open-resources/physics_bank/runs/7099958015?check_suite_focus=true#step:6:27)
AttributeError: 'WebDriver' object has no attribute 'find_element_by_id'
[27](https://github.com/open-resources/physics_bank/runs/7099958015?check_suite_focus=true#step:6:28)
WARNING:tornado.access:404 GET /favicon.ico (127.0.0.1) 0.41ms

The important bit is:

AttributeError: 'WebDriver' object has no attribute 'find_element_by_id'

This seems to have shown up on StackOverflow as well and the fix seems relatively simple. Let me see if I can submit a PR with the fix.

@palewire
Copy link

Yup. I got this too.

File ~/.local/share/virtualenvs/news-homepages-Qlfa7zLV/lib/python3.9/site-packages/altair_saver/savers/_selenium.py:267, in SeleniumSaver._extract(self, fmt)
    265 driver.get(url)
    266 try:
--> 267     driver.find_element_by_id("vis")
    268 except NoSuchElementException:
    269     raise RuntimeError(f"Could not load {url}")

AttributeError: 'WebDriver' object has no attribute 'find_element_by_id'

@palewire
Copy link

This error is now surfacing in Altair's unittests.

jairideout added a commit to onecodex/onecodex that referenced this issue Jul 27, 2022
This should (hopefully) fix the failing HTML & PDF exporter tests in `test_reports.py`. See altair-viz/altair_saver#104 and vega/altair#2624

Closes DEV-7078
jairideout added a commit to onecodex/onecodex that referenced this issue Jul 27, 2022
This should (hopefully) fix the failing HTML & PDF exporter tests in `test_reports.py`. See altair-viz/altair_saver#104 and vega/altair#2624

Closes DEV-7078
jairideout added a commit to onecodex/onecodex that referenced this issue Jul 27, 2022
This should (hopefully) fix the failing HTML & PDF exporter tests in `test_reports.py`. See altair-viz/altair_saver#104 and vega/altair#2624

Closes DEV-7078
jairideout added a commit to onecodex/onecodex that referenced this issue Jul 27, 2022
This should (hopefully) fix the failing HTML & PDF exporter tests in `test_reports.py`. See altair-viz/altair_saver#104 and vega/altair#2624

Closes DEV-7078
@mcp292
Copy link

mcp292 commented Aug 2, 2022

Workaround:

pip install selenium==4.2.0

@rencryptofish
Copy link

Workaround:

pip install selenium==4.2.0

thanks this fixed the issue with altair-saver = "==0.5.0"

@soilstack
Copy link

soilstack commented Mar 9, 2023

I'm encountering AttributeError: 'Chart' object has no attribute 'get_figure'

altair_saver.__version__ = 0.5.0
selenium.__version__ = 4.8.2.

I'm working inside a conda distribution so attempting to downgrade my selenium fails

conda install selenium=4.2.0
fails:

PackagesNotFoundError: The following packages are not available from current channels:

  - selenium=4.2.0

Current channels:

  - https://repo.anaconda.com/pkgs/main/win-64
  - https://repo.anaconda.com/pkgs/main/noarch
  - https://repo.anaconda.com/pkgs/r/win-64
  - https://repo.anaconda.com/pkgs/r/noarch
  - https://repo.anaconda.com/pkgs/msys2/win-64
  - https://repo.anaconda.com/pkgs/msys2/noarch

How can I work around this? I have chrome 110 installed and the correct chromedriver for that version of chrome.

=================

update: conda install selenium=3.141.0 succeeded and now altair-saver is working for me

@saiwing-yeung
Copy link

@soilstack Have you specified to use the conda-forge channel?
https://anaconda.org/conda-forge/selenium

@joelostblom
Copy link
Member

Since Altair 5.2, the functionality of Altair Saver is now available in Altair via the vl-convert package. Most of the functionality has been available since 5.0, and the main addition in 5.2 was PDF export. See the docs on how to save charts for more details

We are going to archive this repo, so I'm closing all the open issues and PRs before doing so. Try out the new options for saving charts mentioned above and if you run into issues, please open an issue directly in the altair or vl-convert repo.

@joelostblom joelostblom closed this as not planned Won't fix, can't repro, duplicate, stale Mar 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants