I have a website where user can send his photo to a contest. He clicks to choose file from disk and sends it using Firefox.
I want to test my form with Selenium in C#. I know there is a way to send local file path to input file, but i want to test it including Windows 7 file open dialog.
I've written test, click a button to open file dialog and execute this code to set path to local file inside the File Upload Dialog:
System.Windows.Forms.SendKeys.SendWait(localFile);
Thread.Sleep(1500);
System.Windows.Forms.SendKeys.SendWait("{ENTER}");
It works properly when i test it on my profile on Windows. But i have another profile on Windows where website test is running. So i use my personal profile to use Windows, and tests run on the second profile. When i set the test to be executed on my second profile than it is not executed properly.
When i switch to this profile i see a dialog window and the localFile url is typed into the File Dialog at the very moment when i switched to the profile. It seems like SendWait does not work when i am not active in the profile where test is executed.
So my question is: what to do to make the test handle File Dialog properly on a profile i am not active when test is executed?