0

I am trying to automate a web process using selenium.

The process clicks an "upload image" button and then sends the file name to a Windows File Explorer Window.

My solution as of now is to use selenium to click the "upload image" button and then to use a VBscript, via the sendKeys command, to send the file name to the active windows file explorer window.

As others have noted this causes some issues, foremost of which is that accidently focusing on another window sends the keys to it instead of file explorer.

I'm trying to make this process less "hacky".

I know MS Edge uses a Windows Utilities subprocess to open the file explorer window.

As of now, I can get the Id of this subprocess, but in a round about way, namely, by finding the most recently created subprocess managed by the browser. Obviously, this is a far cry from automation.

Using windows PowerShell, I've I have not managed to locate any information about this subprocess that could help with my automation task. For example, I could not get any unique identifying characteristics of the subprocess other than its process Id and I can't access its standard input. So far, all I can do is kill the sub process.

What I'm looking for is a rough outline (no code, just an architectural overview) of what it would take to do in PowerShell, what MS edge does after invoking the Windows Utility subprocess to upload a file to a website.

If someone has any suggestions on books I can read, I'd appreciate that as well.

Just looking for someone to point me in the right direction, really.

Harry
  • 11
  • 2
  • If the ultimate goal is to upload a file, would it make sense to just programmatically upload the file to the server? – Simon MᶜKenzie Sep 03 '22 at 22:26
  • There is no need to tinker with any sub process as the file explorer window supports the regular [Windows UI automation](https://en.wikipedia.org/wiki/Microsoft_UI_Automation) interfaces. This means you can programmatically set the name of the file to upload within the edit control, without having to resort to `SendKeys` and then invoke the Ok button, again without `SendKeys`. The basic information how to get started with automating explorer can be found in [this answer](https://stackoverflow.com/a/73541499/7571258). – zett42 Sep 03 '22 at 22:47
  • 1
    @SimonMᶜKenzie Perhaps, but I don't know enough about programmatic communication with servers. Still a newbie. – Harry Sep 04 '22 at 01:54
  • If you do go for the "direct upload" approach, [this article](https://dotsh.no/2021/04/20/powershell-uploading-files-with-multipart-form-data/) looks like it might be a good place to start. It's just about how to replicate the payload sent by the browser when uploading a file. – Simon MᶜKenzie Sep 04 '22 at 10:03

0 Answers0