Hello!
This is my nested try code block:
#Searches for the "Email is not valid" popup
time.sleep(0.3)
driver.find_element(by="xpath", value="/html/body/div/form[1]/div/div/div[2]/div[1]/div/div/div/div/div[1]/div[3]/div/div/div/div[2]/div[1]/div")
except: THIS SHOULD EXECUTE
try:
#Email is Valid, writes in Password
driver.find_element(by="id", value="passwordEntry").send_keys(Password + Keys.ENTER)
except:
driver.close()
return "Invalid"
else:
try:
#Password is Valid, searches for the "Yes" button, meaning no 2FA
driver.find_element(by="xpath", value="/html/body/div/div/div/div/div/div[1]/div/div/div/div/form")
except:
try:
driver.find_element(by="xpath", value="/html/body/div[1]/div/div/div[2]/div/div[1]/div[2]/div/div[2]/div/div/form/div/div[6]/div/div/input")
except:
#Doesn't find the "NEXT" or "YES" button but a 2fa screen instead
return "2FA"
else:
#Finds a "NEXT" button
with open("cookie.pkl", "wb") as file:
pickle.dump(cookies, file)
return "Valid"
finally:
driver.close()
else:
#Finds the "Yes" button, account is Valid.
with open("cookie.pkl", "wb") as file:
pickle.dump(cookies, file)
return "Valid"
finally:
driver.close()
else:
driver.quit()
return "Invalid"```