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

Incompatible with selenium 4.3.0 #2650

Closed
cgbahk opened this issue Jul 6, 2022 · 2 comments
Closed

Incompatible with selenium 4.3.0 #2650

cgbahk opened this issue Jul 6, 2022 · 2 comments
Labels

Comments

@cgbahk
Copy link

cgbahk commented Jul 6, 2022

TL;DR;

chart.save(...) doesn't work with selenium 4.3.0 (released 2022/6/24), due to API deprecation

Detail

When I try to save chart in png or svg using chart.save(...), it fails like this

AttributeError: 'WebDriver' object has no attribute 'find_element_by_id'
Full error trace
Traceback (most recent call last):
  ...
  File "<REDACTED>.py", line 62, in main
    chart.save("image.png")
  File "<REDACTED>/lib/python3.8/site-packages/altair/vegalite/v4/api.py", line 488, in save
    result = save(**kwds)
  File "<REDACTED>/lib/python3.8/site-packages/altair/utils/save.py", line 116, in save
    mimebundle = spec_to_mimebundle(
  File "<REDACTED>/lib/python3.8/site-packages/altair/utils/mimebundle.py", line 60, in spec_to_mimebundle
    return altair_saver.render(spec, format, mode=mode, **kwargs)
  File "<REDACTED>/lib/python3.8/site-packages/altair_saver/_core.py", line 257, in render
    mimebundle.update(saver.mimebundle(fmt))
  File "<REDACTED>/lib/python3.8/site-packages/altair_saver/savers/_saver.py", line 90, in mimebundle
    bundle[mimetype] = self._serialize(fmt, "mimebundle")
  File "<REDACTED>/lib/python3.8/site-packages/altair_saver/savers/_selenium.py", line 284, in _serialize
    out = self._extract(fmt)
  File "<REDACTED>/lib/python3.8/site-packages/altair_saver/savers/_selenium.py", line 267, in _extract
    driver.find_element_by_id("vis")
AttributeError: 'WebDriver' object has no attribute 'find_element_by_id'

This stackoverflow answer was helpful to find why it fails:

Selenium 4.3.0

  • Deprecated find_element_by_* and find_elements_by_* are now removed (# 10712)

(from https://stackoverflow.com/a/72773269/4214521)

selenium 4.3.0 released on 2022/6/24 https://github.com/SeleniumHQ/selenium/releases/tag/selenium-4.3.0

Reproduction

I guess any save() call can reproduce it. For example, I can reproduce this issue with most simple example: 🔗

save() successful case:

$ cat requirements.txt

selenium<4.3.0
altair
altair_saver
vega-datasets
requests
pip list
$ pip list

Package             Version
------------------- ---------
altair              4.2.0
altair-data-server  0.4.1
altair-saver        0.5.0
altair-viewer       0.4.0
async-generator     1.10
attrs               21.4.0
certifi             2022.6.15
cffi                1.15.1
charset-normalizer  2.1.0
cryptography        37.0.4
entrypoints         0.4
h11                 0.13.0
idna                3.3
importlib-resources 5.8.0
Jinja2              3.1.2
jsonschema          4.6.1
MarkupSafe          2.1.1
numpy               1.23.0
outcome             1.2.0
pandas              1.4.3
pip                 22.1.2
pkg_resources       0.0.0
portpicker          1.5.2
psutil              5.9.1
pycparser           2.21
pyOpenSSL           22.0.0
pyrsistent          0.18.1
PySocks             1.7.1
python-dateutil     2.8.2
pytz                2022.1
requests            2.28.1
selenium            4.2.0
setuptools          44.0.0
six                 1.16.0
sniffio             1.2.0
sortedcontainers    2.4.0
toolz               0.11.2
tornado             6.2
trio                0.21.0
trio-websocket      0.9.2
urllib3             1.26.9
vega-datasets       0.9.0
wsproto             1.1.0
zipp                3.8.0

--

save() failure case (with above error log):

$ cat requirements.txt

selenium==4.3.0
altair
altair_saver
vega-datasets
requests
pip list
Package             Version
------------------- ---------
altair              4.2.0
altair-data-server  0.4.1
altair-saver        0.5.0
altair-viewer       0.4.0
async-generator     1.10
attrs               21.4.0
certifi             2022.6.15
cffi                1.15.1
charset-normalizer  2.1.0
cryptography        37.0.4
entrypoints         0.4
h11                 0.13.0
idna                3.3
importlib-resources 5.8.0
Jinja2              3.1.2
jsonschema          4.6.1
MarkupSafe          2.1.1
numpy               1.23.0
outcome             1.2.0
pandas              1.4.3
pip                 22.1.2
pkg_resources       0.0.0
portpicker          1.5.2
psutil              5.9.1
pycparser           2.21
pyOpenSSL           22.0.0
pyrsistent          0.18.1
PySocks             1.7.1
python-dateutil     2.8.2
pytz                2022.1
requests            2.28.1
selenium            4.3.0
setuptools          44.0.0
six                 1.16.0
sniffio             1.2.0
sortedcontainers    2.4.0
toolz               0.11.2
tornado             6.2
trio                0.21.0
trio-websocket      0.9.2
urllib3             1.26.9
vega-datasets       0.9.0
wsproto             1.1.0
zipp                3.8.0
@cgbahk cgbahk added the bug label Jul 6, 2022
@tempdata73
Copy link
Contributor

tempdata73 commented Jul 13, 2022

This is due to the altair_saver package, which uses find_element_by_id. There's a possible fix (see #105). As per #2624, the authors are waiting to fix this issue until the next package release.

For the moment try to use older versions of selenium.

@cgbahk
Copy link
Author

cgbahk commented Jul 13, 2022

Oh, thanks, altair-viz/altair_saver#104 seems reported first, for same issue.

Closing as duplication. I would follow altair-viz/altair_saver#104

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants