自从chrome版本更新后,我遇到了
问题是,只有当我没有使用
我需要在Jupiter笔记本中运行此代码(我想我不能使用sudo选项?(
WebDriverException
问题是,只有当我没有使用
sudo
选项时,才会出现错误我需要在Jupiter笔记本中运行此代码(我想我不能使用sudo选项?(
有人能告诉我解决办法吗?!谢谢你。。。
这是我在下面的代码
chrome_options = webdriver.ChromeOptions()
# chrome_options = Options()
ua = UserAgent(verify_ssl=False)
userAgent = ua.random
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('disable-gpu')
chrome_options.add_argument('lang=ko_KR')
chrome_options.add_argument(f'user-agent={userAgent}')
driver = webdriver.Chrome(executable_path='/home/xx/xxx/xxxx/chromedriver-103',
options=chrome_options)
这是我在下面的错误信息
---------------------------------------------------------------------------
WebDriverException Traceback (most recent call last)
<ipython-input-7-3a252780e886> in <module>
12
13 driver = webdriver.Chrome(executable_path='/home/fds_pl/shellCompany/source/chromedriver-103',
---> 14 options=chrome_options)
~/yerinvirtualenv/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()
~/yerinvirtualenv/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)
~/yerinvirtualenv/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']
~/yerinvirtualenv/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))
~/yerinvirtualenv/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: DevToolsActivePort file doesn't exist
尝试使用选项
chrome_options.add_argument("--crash-dumps-dir=/tmp")