Error Thrown at end of code even though it finishes -Python Selenium

Viewed 21

Working on a program that resets passwords for website my company uses. The program runs like it is supposed to and finishes but throws an error that is below at the end even though it completes the full program. The code and the error are below. Any help of where I can get this to finish correctly and not throwing a error is greatly appreciated.

The Code

    try:
         driver1.find_element(By.XPATH, '//*[@id="submit-button"]').click()
         
         while WebDriverWait(driver1, 20).until(EC.presence_of_element_located((By.XPATH, "//div[@class='error-content']"))):
               time.sleep(3)
               driver1.find_element(By.XPATH, "//a[@id='password-reset']").click()
               driver1.find_element(By.XPATH, "//span[normalize-space()='CONTINUE']").click()
               outlook = win32.Dispatch('outlook.application')
               mail = outlook.CreateItem(0)
               mail.To = ADconnect.email  
               mail.Subject = "DAT Account Password Change"  
               mail.Body = (ADconnect.FirstN + " your DAT account has been transitioned over to email login. You should receive a email from DAT with a link to change your password. \n \n" + "Please see the log in info below:\n \n"
                              "Username: " + ADconnect.email + "\nPassword: total2 \n\n"
                              "You can log in with the below link \n"
                              "https://power.dat.com")
               mail.Send()
               print("Email sent")
               # driver1.quit()
               break
               
      except TimeoutException:
                  print("no error")
      
      while WebDriverWait(driver1, 20).until(EC.presence_of_element_located((By.XPATH, "//mat-dialog-content[@class='mat-dialog-content dialog-content']"))):
               # driver1.title("https://migration.dat.com/step1")
         try:
               print("DID IT MAkE IT TO HERE")
               time.sleep(3)
               driver1.find_element(By.XPATH, "//button[@id='get-started-button']").click()
               WebDriverWait(driver1, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@id='email-input']"))).send_keys(ADconnect.email)
               WebDriverWait(driver1, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@id='mat-input-1']"))).send_keys(ADconnect.email)
               WebDriverWait(driver1, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@id='mat-input-2']"))).send_keys("TotalLog1")
               WebDriverWait(driver1, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@id='mat-input-3']"))).send_keys("TotalLog1")
               driver1.find_element(By.XPATH, "//span[@class='mat-button-wrapper']").click()
               driver1.find_element(By.XPATH, "//span[normalize-space()='CONFIRM']").click()
               outlook = win32.Dispatch('outlook.application')
               mail = outlook.CreateItem(0)
               mail.To = ADconnect.email  
               mail.Subject = "DAT Account Password Change"  
               mail.Body = (ADconnect.FirstN + " your DAT account has been transitioned over to email login. You should receive a email from DAT to confirm your email. \n \n" + "Please see the log in info below that you will use after confirming your email:\n \n"
                              "Username: " + ADconnect.email + "\nPassword: TotalLog1 \n\n"
                              "You can log in with the below link \n"
                              "https://power.dat.com")
               mail.Send()
               print("Email sent")
               # driver1.quit() 
               break
         except TimeoutException:
                  print("no error")

      try:
            confirm = (WebDriverWait(driver1, 20).until(EC.visibility_of_element_located((By.XPATH, "//a[@id='user-salutation']"))).get_attribute("innerHTML"))   
            
            while confirm == ("Hi " + NewUserName):
               print(confirm)
               print("Users password has been changed")
               outlook = win32.Dispatch('outlook.application')
               mail = outlook.CreateItem(0)
               mail.To = ADconnect.email  
               mail.Subject = "DAT Account Password Change"  
               mail.Body = (ADconnect.FirstN + " your DAT account password has been changed!\n \n" + "Please see the log in info below:\n \n"
                              "Username: " + NewUserName + "\nPassword: total2 \n\n"
                              "You can log in with the below link \n"
                              "https://power.dat.com")
               mail.Send()
               # driver1.quit()
               break
      except TimeoutException:
                  print("no error")
            
      
      driver1.quit() 

The Error

Traceback (most recent call last):
  File "c:\Users\Justin\DasScript\DATscriptFIN\Driver.py", line 3, in <module>
    DATSQL.chckAcct()
  File "c:\Users\Justin\DasScript\DATscriptFIN\DATSQL.py", line 67, in chckAcct
    PassChngWeb.ChangeLogin(AdminUser, AdminPassword)
  File "c:\Users\Justin\DasScript\DATscriptFIN\PassChngWeb.py", line 167, in ChangeLogin
    TstAcct()
  File "c:\Users\Justin\DasScript\DATscriptFIN\PassChngWeb.py", line 117, in TstAcct
    while WebDriverWait(driver1, 20).until(EC.presence_of_element_located((By.XPATH, "//mat-dialog-content[@class='mat-dialog-content dialog-content']"))):
  File "C:\Users\Justin\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\support\wait.py", line 90, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
Stacktrace:
Backtrace:
        Ordinal0 [0x009EDF13+2219795]
        Ordinal0 [0x00982841+1779777]
        Ordinal0 [0x0089423D+803389]
        Ordinal0 [0x008C3025+995365]
        Ordinal0 [0x008C31EB+995819]
        Ordinal0 [0x008F0F52+1183570]
        Ordinal0 [0x008DE844+1108036]
        Ordinal0 [0x008EF192+1175954]
        Ordinal0 [0x008DE616+1107478]
        Ordinal0 [0x008B7F89+950153]
        Ordinal0 [0x008B8F56+954198]
        GetHandleVerifier [0x00CE2CB2+3040210]
        GetHandleVerifier [0x00CD2BB4+2974420]
        GetHandleVerifier [0x00A86A0A+565546]
        GetHandleVerifier [0x00A85680+560544]
        Ordinal0 [0x00989A5C+1808988]
        Ordinal0 [0x0098E3A8+1827752]
        Ordinal0 [0x0098E495+1827989]
        Ordinal0 [0x009980A4+1867940]
        BaseThreadInitThunk [0x76ADFA29+25]
        RtlGetAppContainerNamedObjectPath [0x776D7B5E+286]
        RtlGetAppContainerNamedObjectPath [0x776D7B2E+238]
0 Answers
Related