Issue
Im trying to automate a web-game with python using selenium webdriver. There you have some missions and you have to send specific vehicles to a mission. You've a button where you can click on to choose a vehicle. If a vehicle is'nt available, a alert will present.
And that's the problem. I get an UnexpectedAlertPresentException and I tried to pass it like this:
try:
acc_veh_btn = driver.find_element_by_xpath("//*[@class='tab-
content']/div[{}]/div[1]/div[*]/a[@title='{}']".format(tab_index, acc_veh_name.strip())).click()
sleep(0.1)
except UnexpectedAlertPresentException:
alert = driver.switch_to_alert()
alert.accept()
veh_ava = False
pass
else:
pass
I don't know if this is the right way to handle this... anyway I get an UnexpectedAlertPresentException
Solution
Answer is... simple. The alert took to long to appear so the alert came when the program wasnt in the try/except. Also the switch to the alert wasnt needed. It close everythings on his own
Answered By - Porta
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.