Open sirLessClicks opened 2 years ago
whatever you do, remove the time sleepOn Nov 30, 2021 00:51, sirLessClicks @.***> wrote: I am trying to open a site multiple times in a loop to test if different credentials have expired so that I can notify our users. I'm achieving this by opening the database, getting the records, calling the chrome driver to open the site, and inputting the values into the site. The first loop works but when the next one initiates the driver hangs and eventually outputs the error: "unknown error: cannot connect to chrome at 127.0.0.1:XXXX from chrome not reachable"
This error commonly occurs when there is already an instance running. I have tried to prevent this by using both driver.close() and driver.quit() when the first loop is done but to no avail. I have taken care of all other possibilities of detection such as using proxies, different user agents, and also using the undetected_chromedriver by https://github.com/ultrafunkamsterdam/undetected-chromedriver. The core issue I am looking to solve is being able to open an instance of the chrome driver, close it and open it back again all in the same execution loop until all the credentials I am testing have finished. I have abstracted the code and provided an isolated version that replicates the issue:
import undetected_chromedriver.v2 as uc
import time
options = uc.ChromeOptions()
options.add_argument('--no-first-run')
driver = uc.Chrome(options=options)
length = 8 count = 0 if count < length: print("Im outside the loop") while count < length: print("This is loop ",count) time.sleep(2) with driver: print("Im inside the loop") count =+ 1 driver.get("https://google.com") time.sleep(5) print("Im at the end of the loop") driver.quit() # Used to exit the browser, and end the session
Any solutions, suggestions, or workarounds would be greatly appreciated.
—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or unsubscribe.Triage notifications on the go with GitHub Mobile for iOS or Android.
Is the time.sleep no longer used to control the flow of the application? I use time.sleep in all other aspects of my application. I would appreciate any insight as to how to get a new instance of the driver in the loop. Also, any insight into the driver itself if it doesn't all open multiple instances in the same execution.
Have you solved this problem?
Have the same issue
Also running into this
I am trying to open a site multiple times in a loop to test if different credentials have expired so that I can notify our users. I'm achieving this by opening the database, getting the records, calling the chrome driver to open the site, and inputting the values into the site. The first loop works but when the next one initiates the driver hangs and eventually outputs the error:
This error commonly occurs when there is already an instance running. I have tried to prevent this by using both driver.close() and driver.quit() when the first loop is done but to no avail. I have taken care of all other possibilities of detection such as using proxies, different user agents, and also using the undetected_chromedriver by https://github.com/ultrafunkamsterdam/undetected-chromedriver.
The core issue I am looking to solve is being able to open an instance of the chrome driver, close it and open it back again all in the same execution loop until all the credentials I am testing have finished. I have abstracted the code and provided an isolated version that replicates the issue:
Any solutions, suggestions, or workarounds would be greatly appreciated.