1

I am trying to automate an application that downloads files automatically. I am using Selenium with Python. But my application crashes after some time throwing the Aw, Snap error and my script stops showing the error message:

NoSuchWindowException: no such window: target window already closed

So my ideas was to restart the application by including the except statement as shown:

except NoSuchWindowException as ex4:
    print("Exception4 has been thrown"+str(ex4))
    driver.refresh()
    driver.implicitly_wait(20)
    username=driver.find_element_by_id("user")
    username.clear()
    username.send_keys("")
    password=driver.find_element_by_id("pw")
    password.clear()
    password.send_keys("")
    driver.implicitly_wait(20)
    login=driver.find_element_by_id("loginButton")
    login.click() 

I have tried the following in my except clause but didn't work :

  1. driver.refresh()
  2. Click on back button: driver.execute_script("window.history.go(-1)")
  3. driver.get("URL")
  4. driver.quit This worked but when I tried to relaunch the application using driver.get("URL") , I got the below error:

"error: [Errno 10061] No connection could be made because the target machine actively refused it"

Please suggest how I can resolve this issue. Below is the error image: enter image description here

Thanks

Mohd
  • 5,523
  • 7
  • 19
  • 30
Vishnu
  • 110
  • 2
  • 10

0 Answers0