diff --git a/.github/workflows/jdi-python.yml b/.github/workflows/jdi-python.yml index cf48d7c..b3b6e01 100644 --- a/.github/workflows/jdi-python.yml +++ b/.github/workflows/jdi-python.yml @@ -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 diff --git a/utils/get_driver.py b/utils/get_driver.py index 946892b..930e82a 100644 --- a/utils/get_driver.py +++ b/utils/get_driver.py @@ -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()