selenium window_handles freezes in python

Asked 2 months ago, Updated 2 months ago, 2 views

The driver.window_handles will freeze with the code below.
It does not freeze all the time, but occurs about once every 10 times.
There are no error messages or exceptions.

Switch control to a window with a specific title
That's it.

I know there's a data dependency, so click the button before this code and
Freeze occurs if a window is included that starts immediately and loads the screen. Yes, freeze
if there is a window that takes a long time to load the screen. It does not occur.

allHandles=driver.window_handles

for handle in (allHandles):
    print("***title=", driver.title)
    driver.switch_to_window(handle)
    time.sleep(1)

    if((driver.title==title) or("Error" in driver.title)):
        print("***switch_to_window=",driver.title)
        break

I look forward to hearing from you.

python selenium

2022-09-30 14:29

1 Answers

Other than switch_to.window(), I am stuck in the same place.
Even if I try to avoid it with try~exception, I am having trouble with not outputting errors and not issuing exceptions on that line. Please let me know if you find a workaround.
By the way, I'm guessing you're running it over and over again, but are there any WebDriver processes left, a lot of browser processes left, or Powershell or Python sessions per VS Code on the right side of the screen? Once you delete everything, even if you can't avoid freezing (I want to know), the frequency of freezing may decrease.


2022-09-30 14:29

If you have any answers or tips


© 2022 OneMinuteCode. All rights reserved.