Closed sugizo closed 3 years ago
pip install -U webdriver-manager selenium
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager driver = webdriver.Chrome(ChromeDriverManager().install() )
[WDM] - ====== WebDriver manager ====== --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-12-b024ad3f5b00> in <module> 1 from webdriver_manager.chrome import ChromeDriverManager ----> 2 driver = webdriver.Chrome(ChromeDriverManager().install() ) /srv/conda/envs/notebook/lib/python3.6/site-packages/webdriver_manager/chrome.py in __init__(self, version, os_type, path, name, url, latest_release_url, chrome_type, log_level, print_first_line, cache_valid_range) 28 url=url, 29 latest_release_url=latest_release_url, ---> 30 chrome_type=chrome_type) 31 32 def install(self): /srv/conda/envs/notebook/lib/python3.6/site-packages/webdriver_manager/driver.py in __init__(self, name, version, os_type, url, latest_release_url, chrome_type) 52 latest_release_url) 53 self.chrome_type = chrome_type ---> 54 self.browser_version = chrome_version(chrome_type) 55 56 def get_os_type(self): /srv/conda/envs/notebook/lib/python3.6/site-packages/webdriver_manager/utils.py in chrome_version(browser_type) 140 version = re.search(pattern, stdout) 141 if not version: --> 142 raise ValueError(f'Could not get version for Chrome with this command: {cmd}') 143 current_version = version.group(0) 144 return current_version ValueError: Could not get version for Chrome with this command: google-chrome --version || google-chrome-stable --version
from webdriver_manager.chrome import ChromeDriverManager from webdriver_manager.utils import ChromeType driver = webdriver.Chrome(ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install() )
[WDM] - ====== WebDriver manager ====== --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-13-a64aa57a9042> in <module> 1 from webdriver_manager.chrome import ChromeDriverManager 2 from webdriver_manager.utils import ChromeType ----> 3 driver = webdriver.Chrome(ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install() ) /srv/conda/envs/notebook/lib/python3.6/site-packages/webdriver_manager/chrome.py in __init__(self, version, os_type, path, name, url, latest_release_url, chrome_type, log_level, print_first_line, cache_valid_range) 28 url=url, 29 latest_release_url=latest_release_url, ---> 30 chrome_type=chrome_type) 31 32 def install(self): /srv/conda/envs/notebook/lib/python3.6/site-packages/webdriver_manager/driver.py in __init__(self, name, version, os_type, url, latest_release_url, chrome_type) 52 latest_release_url) 53 self.chrome_type = chrome_type ---> 54 self.browser_version = chrome_version(chrome_type) 55 56 def get_os_type(self): /srv/conda/envs/notebook/lib/python3.6/site-packages/webdriver_manager/utils.py in chrome_version(browser_type) 140 version = re.search(pattern, stdout) 141 if not version: --> 142 raise ValueError(f'Could not get version for Chrome with this command: {cmd}') 143 current_version = version.group(0) 144 return current_version ValueError: Could not get version for Chrome with this command: chromium --version || chromium-browser --version
from webdriver_manager.firefox import GeckoDriverManager driver = webdriver.Firefox(executable_path=GeckoDriverManager().install() )
[WDM] - ====== WebDriver manager ====== [WDM] - Driver [/home/jovyan/.wdm/drivers/geckodriver/linux64/v0.29.0/geckodriver] found in cache --------------------------------------------------------------------------- SessionNotCreatedException Traceback (most recent call last) <ipython-input-14-7ebc445374c9> in <module> 1 from webdriver_manager.firefox import GeckoDriverManager ----> 2 driver = webdriver.Firefox(executable_path=GeckoDriverManager().install() ) /srv/conda/envs/notebook/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py in __init__(self, firefox_profile, firefox_binary, timeout, capabilities, proxy, executable_path, options, service_log_path, firefox_options, service_args, desired_capabilities, log_path, keep_alive) 172 command_executor=executor, 173 desired_capabilities=capabilities, --> 174 keep_alive=True) 175 176 # Selenium remote /srv/conda/envs/notebook/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py in __init__(self, command_executor, desired_capabilities, browser_profile, proxy, keep_alive, file_detector, options) 155 warnings.warn("Please use FirefoxOptions to set browser profile", 156 DeprecationWarning, stacklevel=2) --> 157 self.start_session(capabilities, browser_profile) 158 self._switch_to = SwitchTo(self) 159 self._mobile = Mobile(self) /srv/conda/envs/notebook/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py in start_session(self, capabilities, browser_profile) 250 parameters = {"capabilities": w3c_caps, 251 "desiredCapabilities": capabilities} --> 252 response = self.execute(Command.NEW_SESSION, parameters) 253 if 'sessionId' not in response: 254 response = response['value'] /srv/conda/envs/notebook/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py in execute(self, driver_command, params) 319 response = self.command_executor.execute(driver_command, params) 320 if response: --> 321 self.error_handler.check_response(response) 322 response['value'] = self._unwrap_value( 323 response.get('value', None)) /srv/conda/envs/notebook/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py in check_response(self, response) 240 alert_text = value['alert'].get('text') 241 raise exception_class(message, screen, stacktrace, alert_text) --> 242 raise exception_class(message, screen, stacktrace) 243 244 def _value_or_default(self, obj, key, default): SessionNotCreatedException: Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line
from webdriver_manager.microsoft import IEDriverManager driver = webdriver.Ie(IEDriverManager().install() )
[WDM] - ====== WebDriver manager ====== [WDM] - Driver [/home/jovyan/.wdm/drivers/IEDriverServer/Win32/3.150.1/IEDriverServer.exe] found in cache --------------------------------------------------------------------------- PermissionError Traceback (most recent call last) /srv/conda/envs/notebook/lib/python3.6/site-packages/selenium/webdriver/common/service.py in start(self) 75 stderr=self.log_file, ---> 76 stdin=PIPE) 77 except TypeError: /srv/conda/envs/notebook/lib/python3.6/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors) 728 errread, errwrite, --> 729 restore_signals, start_new_session) 730 except: /srv/conda/envs/notebook/lib/python3.6/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session) 1363 err_msg += ': ' + repr(err_filename) -> 1364 raise child_exception_type(errno_num, err_msg, err_filename) 1365 raise child_exception_type(err_msg) PermissionError: [Errno 13] Permission denied: '/home/jovyan/.wdm/drivers/IEDriverServer/Win32/3.150.1/IEDriverServer.exe' During handling of the above exception, another exception occurred: WebDriverException Traceback (most recent call last) <ipython-input-15-1909d6470b74> in <module> 1 from webdriver_manager.microsoft import IEDriverManager ----> 2 driver = webdriver.Ie(IEDriverManager().install() ) /srv/conda/envs/notebook/lib/python3.6/site-packages/selenium/webdriver/ie/webdriver.py in __init__(self, executable_path, capabilities, port, timeout, host, log_level, service_log_path, options, ie_options, desired_capabilities, log_file, keep_alive) 89 log_file=service_log_path) 90 ---> 91 self.iedriver.start() 92 93 RemoteWebDriver.__init__( /srv/conda/envs/notebook/lib/python3.6/site-packages/selenium/webdriver/common/service.py in start(self) 86 raise WebDriverException( 87 "'%s' executable may have wrong permissions. %s" % ( ---> 88 os.path.basename(self.path), self.start_error_message) 89 ) 90 else: WebDriverException: Message: 'IEDriverServer.exe' executable may have wrong permissions. Please download from http://selenium-release.storage.googleapis.com/index.html and read up at https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver
from webdriver_manager.microsoft import EdgeChromiumDriverManager driver = webdriver.Edge(EdgeChromiumDriverManager().install() )
[WDM] - ====== WebDriver manager ====== [WDM] - There is no [linux64] edgedriver for browser in cache [WDM] - Trying to download new driver from https://msedgedriver.azureedge.net/88.0.705.81/edgedriver_linux64.zip --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-16-a065233b15f9> in <module> 1 from webdriver_manager.microsoft import EdgeChromiumDriverManager ----> 2 driver = webdriver.Edge(EdgeChromiumDriverManager().install() ) /srv/conda/envs/notebook/lib/python3.6/site-packages/webdriver_manager/microsoft.py in install(self) 45 46 def install(self): ---> 47 return self._get_driver_path(self.driver) /srv/conda/envs/notebook/lib/python3.6/site-packages/webdriver_manager/manager.py in _get_driver_path(self, driver) 26 return binary_path 27 ---> 28 file = download_file(driver.get_url()) 29 binary_path = self.driver_cache.save_file_to_cache(file, browser_version, 30 driver_name, os_type, driver_version) /srv/conda/envs/notebook/lib/python3.6/site-packages/webdriver_manager/utils.py in download_file(url) 91 log(f"Trying to download new driver from {url}") 92 response = requests.get(url, stream=True) ---> 93 validate_response(response) 94 return File(response) 95 /srv/conda/envs/notebook/lib/python3.6/site-packages/webdriver_manager/utils.py in validate_response(resp) 77 def validate_response(resp): 78 if resp.status_code == 404: ---> 79 raise ValueError("There is no such driver by url {}".format(resp.url)) 80 elif resp.status_code != 200: 81 raise ValueError(resp.json()) ValueError: There is no such driver by url https://msedgedriver.azureedge.net/88.0.705.81/edgedriver_linux64.zip
from webdriver_manager.opera import OperaDriverManager driver = webdriver.Opera(executable_path=OperaDriverManager().install() )
[WDM] - ====== WebDriver manager ====== [WDM] - Driver [/home/jovyan/.wdm/drivers/operadriver/linux64/v.88.0.4324.104/operadriver_linux64/] found in cache --------------------------------------------------------------------------- WebDriverException Traceback (most recent call last) <ipython-input-17-04d157fbd0a3> in <module> 1 from webdriver_manager.opera import OperaDriverManager ----> 2 driver = webdriver.Opera(executable_path=OperaDriverManager().install() ) /srv/conda/envs/notebook/lib/python3.6/site-packages/selenium/webdriver/opera/webdriver.py in __init__(self, desired_capabilities, executable_path, port, service_log_path, service_args, options) 81 service_args=service_args, 82 desired_capabilities=desired_capabilities, ---> 83 service_log_path=service_log_path) /srv/conda/envs/notebook/lib/python3.6/site-packages/selenium/webdriver/opera/webdriver.py in __init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, opera_options, keep_alive) 60 desired_capabilities=desired_capabilities, 61 service_log_path=service_log_path, ---> 62 keep_alive=keep_alive) 63 64 def create_options(self): /srv/conda/envs/notebook/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py in __init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options, keep_alive) 79 remote_server_addr=self.service.service_url, 80 keep_alive=keep_alive), ---> 81 desired_capabilities=desired_capabilities) 82 except Exception: 83 self.quit() /srv/conda/envs/notebook/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py in __init__(self, command_executor, desired_capabilities, browser_profile, proxy, keep_alive, file_detector, options) 155 warnings.warn("Please use FirefoxOptions to set browser profile", 156 DeprecationWarning, stacklevel=2) --> 157 self.start_session(capabilities, browser_profile) 158 self._switch_to = SwitchTo(self) 159 self._mobile = Mobile(self) /srv/conda/envs/notebook/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py in start_session(self, capabilities, browser_profile) 250 parameters = {"capabilities": w3c_caps, 251 "desiredCapabilities": capabilities} --> 252 response = self.execute(Command.NEW_SESSION, parameters) 253 if 'sessionId' not in response: 254 response = response['value'] /srv/conda/envs/notebook/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py in execute(self, driver_command, params) 319 response = self.command_executor.execute(driver_command, params) 320 if response: --> 321 self.error_handler.check_response(response) 322 response['value'] = self._unwrap_value( 323 response.get('value', None)) /srv/conda/envs/notebook/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py in check_response(self, response) 240 alert_text = value['alert'].get('text') 241 raise exception_class(message, screen, stacktrace, alert_text) --> 242 raise exception_class(message, screen, stacktrace) 243 244 def _value_or_default(self, obj, key, default): WebDriverException: Message: unknown error: cannot find Opera binary (Driver info: operadriver=88.0.4324.104 (17905c015d3376dee9cce5dd079a3f4fa906e060-refs/branch-heads/4324_96@{#3}),platform=Linux 4.19.150+ x86_64)
Install chrome browser first