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 :
driver.refresh()
- Click on back button:
driver.execute_script("window.history.go(-1)")
driver.get("URL")
driver.quit
This worked but when I tried to relaunch the application usingdriver.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:
Thanks