Writing tests with c#/nunit and running tests on the same machine i could use System.Windows.Forms, or call Autoit script to handle upload window that selenium cant interact with normally.

But this does not work if i run tests remotely.

Is there any option or trick to upload file using windows file upload dialog when executing tests remotely ?

up vote 1 down vote accepted

Maybe this will help someone

In my case, there was file upload form, thats hidden. So after making it visible (in this case, change class), its possible to use SendKeys and send file path to that element, thus uploading file (if it exists in that VM)

Example:

    string filePath = "C://File//Path/File.txt";
    IJavaScriptExecutor js = driver as IJavaScriptExecutor;
    js.ExecuteScript("document.getElementById('import-file-btn').className = 'btn'");
    Find(import-file-btn).SendKeys(filePath);

No, there is not any option or trick to upload a file using the windows file upload dialog when executing tests remotely.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.