Why switching to alert through selenium is not stable?
For example.
1. Run a code and all good. Everything worked out well.
But if this code is run in a few minutes, then there may be errors.
There is no element you can click on, for example. And so on.
2. On one site there is an alert window.
alert = driver.switch_to_alert()
alert.dismiss()
So I close it. But he works through time. All is well, then errors.
for al in range(3):
try:
alert = driver.switch_to_alert()
alert.dismiss()
time.sleep(randint(1, 3))
except:
pass
I wrote and everything works out as it should.
But I think that this is not beautiful.
Why is everything so unstable?
Thank you very much.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…