0

I am making a bot to scrap me some information from the web via chromedriver. But because this information is sometimes limited to an account (like instagram insights) i need to use several UserData-Folders to save all the logins etc for the chromedriver. To save some memory I made a function "init" which initializes a chromedriver window with the desired UserData-Folder. the function:

def init(userdata):
global driver
warnings.filterwarnings("ignore", category=DeprecationWarning)
option = Options()
option.add_argument("--disable-infobars")
option.add_argument("window-size=fullscreen")
option.add_argument("--disable-extensions")
option.add_argument("--log-level=3")
option.add_argument("--headless")
option.add_argument(r'--user-data-dir=dir\to\UserData' + str(userdata))
option.add_experimental_option("prefs", {"profile.default_content_setting_values.notifications": 1})
driver = webdriver.Chrome(chrome_options=option, executable_path='C:\Windows\chromedriver.exe')

when running the code without headless, it works like a charm. However when using headless it gives the following error:

    raise exception_class(message, screen, stacktrace)
    selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: was killed.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location C:\Program Files\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

1 Answers1

0

chrome_options have been deprecated for quite some time now. Instead you have to use options as follows:

driver = webdriver.Chrome(options=option, executable_path='C:\Windows\chromedriver.exe')
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • thanks for adding to my mysery of deprecated code but after updating it, it still crashes ._. – holzhaker1 Aug 20 '22 at 21:10
  • Can you reboot your system once? – undetected Selenium Aug 20 '22 at 21:12
  • I did, same problem. idk why this gotta happen, but imma just create a new python file for each set of UserData – holzhaker1 Aug 20 '22 at 21:43
  • i got it after literally deconstructing my whole programm. Its the fullscreen which fucks up while going headless, bc theres no screen to fill. edit: however i ran this type of code in the past with chromedriver version < 100 and it worked perfectly fine with fullscreen in headless – holzhaker1 Aug 20 '22 at 21:58