def test_update_no_args(self, dir_function, test_utils): """Latest version of config.DEFAULT_DRIVERS are downloaded to current dir """ tempdir = dir_function['path'] os.chdir(tempdir) result = test_utils.run_command('webdriver-manager update') platform = helpers.get_platform() chromedriver = Chromedriver(tempdir, platform['os_name'], platform['os_bits']) latest_version_chrome = chromedriver.get_latest_remote_version() geckodriver = Geckodriver(tempdir, platform['os_name'], platform['os_bits']) latest_version_gecko = geckodriver.get_latest_remote_version() files = os.listdir() expected_file_chrome = 'chromedriver_{}'.format(latest_version_chrome) if platform['os_name'] == 'windows': expected_file_chrome += '.exe' expected_file_gecko = 'geckodriver_{}'.format(latest_version_gecko) if platform['os_name'] == 'windows': expected_file_gecko += '.exe' assert len(files) == 2 assert expected_file_chrome in files assert expected_file_gecko in files assert 'INFO updating chromedriver' in result assert 'INFO got {}'.format(expected_file_chrome) in result assert 'INFO updating geckodriver' in result assert 'INFO got {}'.format(expected_file_gecko) in result
def test_get_latest_local_version_firefox(self, dir_function, test_utils): os.chdir(dir_function['path']) outputdir = helpers.normalize_outputdir() platform = helpers.get_platform() test_utils.create_test_files(outputdir) driver = Geckodriver(outputdir, 'linux', platform['os_bits']) latest_version = driver.get_latest_local_version() assert latest_version == '2.6'
def test_update_firefox_local_is_up_to_date(self, dir_function, caplog): os.chdir(dir_function['path']) outputdir = helpers.normalize_outputdir() platform = helpers.get_platform() driver = Geckodriver(outputdir, platform['os_name'], platform['os_bits']) latest_version = driver.get_latest_remote_version() dummy_file = 'geckodriver_{}'.format(latest_version) if platform['os_name'] == 'windows': dummy_file += '.exe' with open(os.path.join(outputdir, dummy_file), 'w') as f: f.write('') update('firefox', outputdir) record = caplog.records[0] assert record.levelname == 'INFO' assert record.message == 'geckodriver is up to date'
def test_update_firefox_to_latest(self, dir_function, caplog): os.chdir(dir_function['path']) outputdir = helpers.normalize_outputdir() platform = helpers.get_platform() driver = Geckodriver(outputdir, platform['os_name'], platform['os_bits']) latest_version = driver.get_latest_remote_version() update('firefox', outputdir) files = os.listdir() expected_file = 'geckodriver_{}'.format(latest_version) if platform['os_name'] == 'windows': expected_file += '.exe' assert files == [expected_file] log_records = caplog.records assert log_records[0].levelname == 'INFO' assert log_records[0].message == 'updating geckodriver' assert log_records[1].levelname == 'INFO' assert log_records[1].message == 'got {}'.format(expected_file)
def test_get_driver_full_filename_firefox_windows(self): platform = helpers.get_platform() driver = Geckodriver('', 'windows', platform['os_bits']) full_name = driver.get_driver_full_filename('2.2') assert full_name == 'geckodriver_2.2.exe'