From 98de7f384e8427f64b4fbb1d32d7ed2c543d781d Mon Sep 17 00:00:00 2001 From: Finn <847500023@qq.com> Date: Thu, 11 Jul 2024 10:00:33 +0800 Subject: [PATCH] add chromedriver_py Resolve ChromeDriver automatically using the chromedriver_py package. --- snapshot_selenium/snapshot.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/snapshot_selenium/snapshot.py b/snapshot_selenium/snapshot.py index 7f0de4a..14247d2 100644 --- a/snapshot_selenium/snapshot.py +++ b/snapshot_selenium/snapshot.py @@ -4,6 +4,10 @@ from selenium import webdriver +from selenium.webdriver.chrome.service import Service # set chromedriver +from chromedriver_py import binary_path # add chromedriver + + SNAPSHOT_JS = """ var ele = document.querySelector('div[_echarts_instance_]'); var mychart = echarts.getInstanceByDom(ele); @@ -55,7 +59,10 @@ def make_snapshot( def get_chrome_driver(): options = webdriver.ChromeOptions() options.add_argument("headless") - return webdriver.Chrome(options=options) + return webdriver.Chrome( + options=options, + service=Service(binary_path) # bind chromedriver + ) def get_safari_driver():