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 passelse: pass
I don't know if this is the right way to handle this... anyway I get an UnexpectedAlertPresentException