Switch the default driver for export_png to chromedriver
See original GitHub issueStarted at #5714. All relevant details are repeated here.
PhantomJS is no longer maintained, and at this point using it produces PNGs like these: (a fragment with y-axis) (a fragment with x-axis with rotated labels) Using normal font instead of the italic one does not mitigate the issue.
Currently, I’m using this code to create a driver instance and pass it down to export_png
:
import os
import shutil
from chromedriver_binary.utils import get_chromedriver_path
from selenium.webdriver import Chrome, ChromeOptions
options = ChromeOptions()
# TODO: Remove when https://bugs.chromium.org/p/chromium/issues/detail?id=875241 is fixed
options.binary_location = shutil.which('chrome')
options.add_argument('--headless')
options.add_argument('--disable-gpu')
options.add_argument("--no-sandbox")
options.add_argument("--window-size=2000x2000")
web_driver = Chrome(executable_path=os.path.join(get_chromedriver_path(), 'chromedriver'),
chrome_options=options)
chromedriver_binary
is available by installing python-chromedriver-binary
from the conda-forge
channel. I tested my code with version 2.41.0.
There’s a few of issues:
- Google Chrome can be available under names other than
chrome
- There’s no check for Google Chrome version
- The fixed window size, 2000x2000. It probably could be somehow computed in advance
- Need to check whether this could be used with Chromium - many people use it instead of Google Chrome
Also, maybe at some point there could be a simple option that would use Firefox, but right now it appears to be unusable as it complains about missing log
command.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:9 (7 by maintainers)
Top Results From Across the Web
how to change file download location in Webdriver while ...
CAPABILITY, options); WebDriver driver = new ChromeDriver(cap); ... turn off the download prompt if it appears; set the default directory to ...
Read more >Open, save, or delete files - Chromebook Help
Save a file · On your computer, open Chrome. · At the top right, select More More and then Settings. · At the...
Read more >Most Complete Selenium WebDriver C# Cheat Sheet
Chrome ;. IWebDriver driver = new ChromeDriver();. // NuGet: Selenium.Mozilla. ... Switch to the default document ... Change the default files' save location....
Read more >Adjusting zoom settings in Chrome browser
By default, Chrome sets the zoom level to 100%. To manually adjust the settings, use the Ctrl key and “+” or “-” combos...
Read more >Exporting plots — Bokeh 2.4.3 Documentation
geckodriver for Firefox. ChromeDriver for Chrome / Chromium. You can install these dependencies in various ways. The recommended way is to use conda ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here is a complete example that sets the device pixel ratio to 1.0 to get a correctly scaled image on OSX:
It’s unclear to me yet if just unconditionally setting to 1.0 is always the correct thing to do, or if it is a specific action for a macbook w retina display.
This was resolved in PR #9331.