Skip to content

Commit 11537bb

Browse files
committed
fixing chrome
1 parent b99df5d commit 11537bb

File tree

2 files changed

+11
-36
lines changed

2 files changed

+11
-36
lines changed

.github/workflows/jdi-python.yml

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ jobs:
2727
run: |
2828
python -m pip install --upgrade pip
2929
pip install -r requirements-dev.txt
30+
- name: Install Chrome
31+
run: |
32+
sudo apt-get update
33+
sudo apt-get install -y google-chrome-stable
3034
- name: Download Chrome driver
3135
run: |
3236
cd utils

utils/get_driver.py

+7-36
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,10 @@
1-
# TODO: get last chromedriver version
2-
# TODO: get particular chromedriver version
3-
# TODO: download chromedriver and save to path
4-
# TODO: download and install chrome
5-
# TODO: argparse
6-
import zipfile
7-
8-
import requests
9-
10-
CHROMEDRIVER_URL = "https://chromedriver.storage.googleapis.com"
11-
12-
13-
def download_driver(link, extract_path="."):
14-
filename = link.split("/")[-1]
15-
r = requests.get(link, stream=True)
16-
with open(filename, "wb") as f:
17-
for chunk in r.iter_content():
18-
f.write(chunk)
19-
with zipfile.ZipFile(filename, "r") as zf:
20-
zf.extractall(path=extract_path)
21-
22-
23-
def get_last_release(build=None) -> str:
24-
# TODO: if build is set get last version for this build
25-
if not build:
26-
r = requests.get(f"{CHROMEDRIVER_URL}/LATEST_RELEASE")
27-
else:
28-
r = requests.get(f"{CHROMEDRIVER_URL}/LATEST_RELEASE_{build}")
29-
return r.text
30-
31-
32-
def compose_download_link(build) -> str:
33-
return f"{CHROMEDRIVER_URL}/{build}/chromedriver_win32.zip"
1+
from webdriver_manager.chrome import ChromeDriverManager
2+
from selenium import webdriver
343

4+
def setup_chrome_driver():
5+
driver = webdriver.Chrome(ChromeDriverManager().install())
6+
return driver
357

368
if __name__ == "__main__":
37-
release = get_last_release()
38-
download_link = compose_download_link(build=release)
39-
download_driver(download_link)
9+
driver = setup_chrome_driver()
10+
driver.quit()

0 commit comments

Comments
 (0)