I am looking for any ideas on how best to handle file upload failures in selenium webdriver.
Recently I have been seeing a higher number of failures in my webdriver test suite, the error I am trying to fix is a failure in the Internet Explorer tests caused by a file upload failing.
In webdriver the only way I know to upload a file to an input element is to use the SendKeys()
method and pass the file path to SendKeys()
this works like a charm in chrome and firefox but periodically have had issues with it in Internet Explorer. What appears to happen is the file upload window gets opened but the path is not typed nor is the file uploaded. This leaves the node with a file upload window open, being this is a native window's window and not a webpage selenium cannot interact with the pop up.
The result is the HttpWebRequest
does not get a response back triggering a WebdriverTimoutException. This results in the session getting cleaned up. This causes a cascade of failures for all other tests in the suite as the session has been terminated.
Environment Info:
- Selenium.Webdriver & Seleneium.Support version 3.7.0
- IEDriver 3.7.0
- Testing in IE 11
uploading a file to an input element causing file upload window open
or get rid ofopened up file upload window
? – undetected Seleniumhow to get rid of file upload window
I can wrap calls that may result in this situation but even if I catch this situation I do not know how to "clean up" the file upload window. So subsequent tests can run. – Buster