Google Chrome Closes Immediately After Being Launched With Selenium

Chrome closes immediately after being opened with selenium (Python)

as you called driver var inside function it terminates after the execution of function.

try removing the function and run

Chrome with Selenium closes immediately after trying to start again after closing it with .quit()

Try to assign the new driver to driver variable in the loop:

from selenium import webdriver
driver = webdriver.Chrome()

#some code operations happen here that have nothing to do with the problem I'm having. It just navigates to different URLs.

if current_iteration >= 1500:
print('Iteration greater than 1500. Restarting chrome driver...')
driver.quit()
current_iteration = 0
time.sleep(5)
print('Starting chrome process then waiting 20 seconds...')
driver = webdriver.Chrome() # I've changed this line
time.sleep(20)


Related Topics



Leave a reply



Submit