def test_can_download_driver_as_zip_file(delete_drivers_dir): file = download_file( "http://chromedriver.storage.googleapis.com/2.26/chromedriver_win32.zip" ) assert file.filename == "driver.zip" archive = save_file(file, driver_directory) assert archive.file_path == f"{driver_directory}{os.sep}{file.filename}" assert archive.unpack(driver_directory) == ["chromedriver.exe"]
def test_can_download_driver_as_tar_gz(delete_drivers_dir): file = download_file( "https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux32.tar.gz" ) assert file.filename == 'geckodriver-v0.26.0-linux32.tar.gz' archive = save_file(file, driver_directory) assert archive.file_path == f"{driver_directory}{os.sep}{file.filename}" assert archive.unpack(driver_directory) == ["geckodriver"]
def save_file_to_cache(self, file: File, browser_version, driver_name, os_type, driver_version): path = os.path.join(self._drivers_directory, driver_name, os_type, driver_version) archive = save_file(file, path) files = archive.unpack(path) binary = self.__get_binary(files, driver_name) binary_path = os.path.join(path, binary) self.__save_metadata(browser_version, driver_name, os_type, driver_version, binary_path) log(f"Driver has been saved in cache [{path}]") return binary_path
def test_can_download_chrome_driver(delete_drivers_dir, version): driver = ChromeDriver( name="chromedriver", version=version, os_type="win32", url="http://chromedriver.storage.googleapis.com", latest_release_url= "http://chromedriver.storage.googleapis.com/LATEST_RELEASE", chrome_type=ChromeType.GOOGLE) file = download_file(driver.get_url()) assert file.filename == "driver.zip" archive = save_file(file, driver_directory) assert archive.unpack(driver_directory) == ["chromedriver.exe"]