# File Explorer automation

**URL:** <https://forum.robotframework.org/t/file-explorer-automation/6959>\
**Category:** Robot Framework\
**Created:** [5 March 2024 15:40 UTC](https://forum.robotframework.org/t/file-explorer-automation/6959 "2024-03-05T15:40:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![vdavis345](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/vdavis345/32/3143_2.png) [@vdavis345](https://forum.robotframework.org/u/vdavis345)\
**Post date:** [5 March 2024 15:40 UTC](https://forum.robotframework.org/t/file-explorer-automation/6959/1 "2024-03-05T15:40:46Z")

</div>

I need to automate uploading a document from File explorer. Opened while in chrome…

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/2/2413bec48d90470ff2e8e3d780462daabc8ba191.png)

How would I focus this application and select one of the text files?

---

<div class="post-metadata">

**Author:** ![CharlieScene](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/charliescene/32/3484_2.png) [@CharlieScene](https://forum.robotframework.org/u/CharlieScene)\
**Post date:** [5 March 2024 17:33 UTC](https://forum.robotframework.org/t/file-explorer-automation/6959/2 "2024-03-05T17:33:12Z")

</div>

Hello,

If your page / DOM in Chrome contains an input that you can use as xpath, it would be easier to use SeleniumLibrary _Choose File_ keyword :

```
Choose File //input[@type='file'] c:\user\documents\testBlanketPo.txt

```

This targets the input and loads directly the file into browser.  
It would avoid installing additional libraries to interact with the operating system windows, and ease the functioning and portability of your script if using another OS.

Regards.  
Charlie

---

<div class="post-metadata">

**Author:** ![vdavis345](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/vdavis345/32/3143_2.png) [@vdavis345](https://forum.robotframework.org/u/vdavis345)\
**Post date:** [5 March 2024 17:53 UTC](https://forum.robotframework.org/t/file-explorer-automation/6959/3 "2024-03-05T17:53:34Z")

</div>

![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/7/735c4329f01efc7e8ffa598a8a86fe4baf1886fd.png)  
Here’s the page I am uploading to and the pop-up file explorer above is what I have access to for now.

I can talk to a dev but would probably take a while for that change.

Any other suggestions will be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![CharlieScene](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/charliescene/32/3484_2.png) [@CharlieScene](https://forum.robotframework.org/u/CharlieScene)\
**Post date:** [5 March 2024 18:51 UTC](https://forum.robotframework.org/t/file-explorer-automation/6959/4 "2024-03-05T18:51:47Z")

</div>

Hi,

Not sure any modification is needed.  
Just check/inspect the Dom content, see if the area to upload has an input with @class, @type or else.

Goal is just to target the entry point to load the file.

Regards

---

<div class="post-metadata">

**Author:** ![rasjani](https://avatars.discourse-cdn.com/v4/letter/r/858c86/32.png) [@rasjani](https://forum.robotframework.org/u/rasjani)\
**Post date:** [6 March 2024 10:14 UTC](https://forum.robotframework.org/t/file-explorer-automation/6959/5 "2024-03-06T10:14:19Z")

</div>

Few observations;

Drag and Drop from outside of of the browser Into DOM element will be Very Painful to Not Possible.

What @CharlieScene said, Choose file in selenium context is just fine, you do not need to interact with explorer itself, you just need to know the filename and full path and provide that to

**HOWEVER** Depending on how the file upload is implemented _on the page_, using vanilla “Choose File” keyword wont help either. Reason; Some developers opt out to implement file selecting the native ui dialog, eg, the only way to upload a file for the user is to explicitly drag and drop the file from outside the browser into the form. That can be worked around with by creating a temporary file input to the form, then using Choose file to upload it to that temporary element and once that’s done, Execute Javascript can be used to create artificial drag and drop event. Example library that implements this;

[robotframework-seleniumtestability/src/SeleniumTestability/plugin.py at master · MarketSquare/robotframework-seleniumtestability · GitHub](https://github.com/MarketSquare/robotframework-seleniumtestability/blob/master/src/SeleniumTestability/plugin.py#L503) && [robotframework-seleniumtestability/src/SeleniumTestability/javascript.py at master · MarketSquare/robotframework-seleniumtestability · GitHub](https://github.com/MarketSquare/robotframework-seleniumtestability/blob/master/src/SeleniumTestability/javascript.py#L70)

But still `Choose File` is the most straight forward thing …

---

<div class="post-metadata">

**Author:** ![vdavis345](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/vdavis345/32/3143_2.png) [@vdavis345](https://forum.robotframework.org/u/vdavis345)\
**Post date:** [6 March 2024 22:53 UTC](https://forum.robotframework.org/t/file-explorer-automation/6959/6 "2024-03-06T22:53:44Z")

</div>

![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/c/c4256ceb7d7aae435ada592465d06baf3431da6a.png)  
Only problem is it’s sort of a hidden child element (screenshot above)

![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/9/92a17c51b85a1979bd00b7bfc6b4475547292dc4.png)

RF error:

---

<div class="post-metadata">

**Author:** ![vdavis345](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/vdavis345/32/3143_2.png) [@vdavis345](https://forum.robotframework.org/u/vdavis345)\
**Post date:** [6 March 2024 22:58 UTC](https://forum.robotframework.org/t/file-explorer-automation/6959/7 "2024-03-06T22:58:42Z")

</div>

I initially had it Focus Application - for the **File Explorer** , click on the **txt file** and click **Open**  
but that Library wouldn’t work for headless automation. I will try the links you suggested, thank you 🙂
