Upload file Without clicking upload button

Ask general questions here.
Posts: 1
Joined: Thu Jul 18, 2019 1:33 pm

Upload file Without clicking upload button

Post by nobeatas » Thu Jul 18, 2019 2:37 pm

I read below issue. but i didn’t solve problem ‘ upload file without clicking in selenium ‘
https://www.ranorex.com/forum/filepath- ... 12533.html

The solution presented that using setvalue action and select tagvalue is not working my environment.

I tried setting to below element
<input class=“upload” type=“file” ></input >

Action:Set Value
Name: TagValue
Value: C:\Temp\test.jpg

Result is success, but not working upload file. Nothing happened in browser.
I think that can find target input.

I’m waiting for suggestion or another way.

Thank you for reading ugly english :oops:

Using Ranorex version : 8.3.1
Using browser: chrome ver 75.0.37
Sorry I cannot attach screenshot in my environment.

User avatar
Ranorex Guru
Ranorex Guru
Posts: 6795
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Upload file Without clicking upload button

Post by odklizec » Fri Jul 19, 2019 12:11 pm


Could you please upload a Ranorex snapshot (NOT screenshot) of the web page you are trying to automate? Also, do I understand it right that it must be a webdriver-based solution? Are you going to run your tests via webdriver integration?

Generally speaking, I think you must somehow merge these two codes together:
https://www.ranorex.com/forum/upload-fi ... 11782.html#
https://www.ranorex.com/forum/back-butt ... tml#p55275
Sadly, I'm not using webdriver so I can't tell you how to merge them exactly ;)

Another approach could be using javascript. Try this sample code:

Code: Select all

sing System.Linq;
using OpenQA.Selenium;
// uploadButton: repo element of upload button to click
// path: path to file you want to set in input 
public static void UploadFileWithWebdriver(RepoItemInfo uploadButton, string path)
    var webDriverEndpoint = Host.Current.TryGetAsWebDriverEndpoint();
    IWebDriver driver = webDriverEndpoint.WebDrivers.FirstOrDefault();    
    String script = "document.getElementsByClassName('upload').value='" + path + "';";
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration