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
Check If Values of Multiple Columns Are the Same (Python)
Spliting a Row to Multiple Row Pyspark
How to Clear All Widgets from a Tkinter Window in One Go Without Referencing Them All Directly
How to Convert Signed to Unsigned Integer in Python
Python: Pickle.Load() Raising Eoferror
Pyside - Pyqt:How to Make Set Qtablewidget Column Width as Proportion of the Available Space
How to Replace Nan Values Where the Other Columns Meet a Certain Criteria
Is There an Easy Way in Python to Wait Until Certain Condition Is True
How to Assign and Use Column Headers in Spark
High Pass Filter for Image Processing in Python by Using Scipy/Numpy
Python: How to Match Nested Parentheses With Regex
How to Read a List of Parquet Files from S3 as a Pandas Dataframe Using Pyarrow
Robot Framework Using Python, Key Press Without Selecting Any Button or Element in the Page
Python Replace Single Quotes Except Apostrophes
Python Anaconda - How to Safely Uninstall
Subtract One Dataframe from Another Excluding the First Column Pandas