Как исправить ошибку File «..webdriver.py», line 81, in. __init__ desired_capabilities=desired_capabilities)?

Пытаюсь запустить простейший скрипт с selenium:
#!/usr/bin/python
# This Python file uses the following encoding: utf-8

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
 
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument("--test-type")
options.add_argument("--no-sandbox")
options.add_argument("--disable-setuid-sandbox") 
driver = webdriver.Chrome("/var/chromedriver/chromedriver") 
driver.get('https://google.com')
print(driver.title)
driver.quit()


5c45a523d97d8115432908.jpeg

Всё в порядке с версией, вот:
5c45a578ec0d8487417931.jpeg
  • Вопрос задан
  • 201 просмотр
Решения вопроса 1
half-life
@half-life
Как-то так
from functools import partial
from pathlib import Path
from platform import system

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

ROOT_DIR = Path(__file__).parents[0]

if __name__ == '__main__':
    chrome_options = Options()
    chrome_options.add_argument('--headless')
    chrome_options.binary_location = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
    local_system = system()
    make_path = partial(Path.joinpath, ROOT_DIR, 'chrome_drivers')
    if local_system == 'Linux':
        driver_path = make_path('chromedriver_linux64')
    elif local_system == 'Darwin':
        driver_path = make_path('chromedriver_mac64')
    elif local_system == 'Windows':
        driver_path = make_path('chromedriver_win32.exe')
    else:
        raise RuntimeError('Unknown os system')

    driver = webdriver.Chrome(executable_path=str(driver_path), options=chrome_options)
    driver.get('https://www.google.com/')
    print(driver.title)
    driver.quit()



Плюс всё то что тебе написал Pavel Denisov в комментах.
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы