1

when running my code I get the following error

DeprecationWarning: executable_path has been deprecated, please pass in a Service object
  driver = webdriver.Chrome(ChromeDriverManager().install(),options=chrome_options)`

I understand that the error is saying the executable_path has been depreciated, but I am not seeing where I replace that with the Service() class. my experience with python is limited and would appreciate any guidance.

Here is the code I am running:

from datetime import datetime
import csv
import unidecode
import time
from bs4 import BeautifulSoup
import requests
import os
import json
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By

def driverInitialize():
    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
    chrome_options.add_argument("--start-maximized")
    chrome_options.add_argument("--no-sandbox")
    #chrome_options.add_argument("--headless")
    chrome_options.add_argument("--disable-dev-shm-usage")
    chrome_options.add_argument("--disable-notifications")
    chrome_options.add_argument('--disable-gpu')
    chrome_options.add_argument("--dns-prefetch-disable")
    chrome_options.add_argument('ignore-certificate-errors')
    prefs = {"profile.managed_default_content_settings.images": 2}
    chrome_options.add_experimental_option("prefs", prefs)
    driver = webdriver.Chrome(ChromeDriverManager().install(),options=chrome_options)
    #driver=webdriver.Chrome(options=chrome_options)
    driver.set_page_load_timeout(300)
    return driver
JeffC
  • 22,180
  • 5
  • 32
  • 55
Leila
  • 11
  • 2
  • https://stackoverflow.com/questions/64717302/deprecationwarning-executable-path-has-been-deprecated-selenium-python – Сергей Кох Mar 01 '23 at 05:45
  • add this `from selenium.webdriver.chrome.service import Service` and then run `driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)` – sound wave Mar 03 '23 at 08:13
  • Does this answer your question? [DeprecationWarning: executable\_path has been deprecated selenium python](https://stackoverflow.com/questions/64717302/deprecationwarning-executable-path-has-been-deprecated-selenium-python) – sound wave Mar 03 '23 at 08:13

0 Answers0