Our application has a page where you can upload a file. The code I wrote will use SendKeys()
to send the filepath to the input
tag of the file upload component. However, it's not working on this page.
string filepath = Path.GetFullPath(Directory.GetCurrentDirectory() + @"\..\..\..\Test Files\" + filename);
uploadInput.Click();
uploadInput.SendKeys(filepath);
I've confirmed that the filepath is definitely correct. I've also confirmed that the WebDriver element is definitely correct as well. And, this code does work on a totally separate form of our application. My guess is that the way this file upload component is coded must not be compatible with this method.
What other options do I have for uploading a file? Note, controlling the System file explorer is totally out of the question given the environment our tests are run in.
EDIT: I confirmed that the input tag is indeed receiving the file I specify. However the form's custom validation seems to think nothing was uploaded. This might be something I need to resolve with our developers.