Skip to content

Commit

Permalink
fixing chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
vklonin committed Mar 19, 2024
1 parent b99df5d commit 11537bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 36 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/jdi-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Install Chrome
run: |
sudo apt-get update
sudo apt-get install -y google-chrome-stable
- name: Download Chrome driver
run: |
cd utils
Expand Down
43 changes: 7 additions & 36 deletions utils/get_driver.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,10 @@
# TODO: get last chromedriver version
# TODO: get particular chromedriver version
# TODO: download chromedriver and save to path
# TODO: download and install chrome
# TODO: argparse
import zipfile

import requests

CHROMEDRIVER_URL = "https://chromedriver.storage.googleapis.com"


def download_driver(link, extract_path="."):
filename = link.split("/")[-1]
r = requests.get(link, stream=True)
with open(filename, "wb") as f:
for chunk in r.iter_content():
f.write(chunk)
with zipfile.ZipFile(filename, "r") as zf:
zf.extractall(path=extract_path)


def get_last_release(build=None) -> str:
# TODO: if build is set get last version for this build
if not build:
r = requests.get(f"{CHROMEDRIVER_URL}/LATEST_RELEASE")
else:
r = requests.get(f"{CHROMEDRIVER_URL}/LATEST_RELEASE_{build}")
return r.text


def compose_download_link(build) -> str:
return f"{CHROMEDRIVER_URL}/{build}/chromedriver_win32.zip"
from webdriver_manager.chrome import ChromeDriverManager
from selenium import webdriver

def setup_chrome_driver():
driver = webdriver.Chrome(ChromeDriverManager().install())
return driver

if __name__ == "__main__":
release = get_last_release()
download_link = compose_download_link(build=release)
download_driver(download_link)
driver = setup_chrome_driver()
driver.quit()

0 comments on commit 11537bb

Please sign in to comment.