Issue
i use C# Selenium in my App, i click on file input and (open window) file dialog show up. I need to pass filepath and then hit enter (return) key.
Requirement: work even if current user is signed out, desktop is locked, RDP session closed
- Selenium built-in SendKeys did not work at all.
- Windows.Forms.SendKeys.SendWait() work not so excatly, path submit is ok, in order to hit enter, process wait for user session. Nuget -
- InputSimulator / WinApi - UAC (UIPI) access denied
Any possibility to submit file without opening dialog in javascript ?
Thanks
Example using Selenium
var button = web.FindElementByXPath("//span[@class='upload']");
button.Click();
Not working
button.SendKeys("path"); //not input element
Windows.Forms.SendKeys.SendWait("..."); //not working for closed user session
InputSimulator.SimulateTextEntry("path"); //access denied because of Windows UIPI
Solution
In case explained above, there was no HTML input of file type (see comments). Open file dialog popup after click on other HTML element. Passing any string to that element had no success.
The best and probably the easiest solution which i used in c# application was using AutoIT.
Install-Package AutoItX.Dotnet
Call after click to open dialog
AutoItX.ControlSend("Open", "", "", _sysPathToTheFile);
AutoItX.ControlSend("Open", "", "", "{ENTER}");
Optionally, you can call
WinActivate(), WinWaitActive()...
But ControlSend() works well also when window is in background or in my case, use session is closed, locked screen and similiar situations.
Answered By - apincik
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.