The Easy way of uploading a file is simple case of just finding the element and typing the absolute path of the document into it.
It is mandatory that it works only when the textbox is enabled. So please make sure that the input element is visible. In the below example 'uploadsubmit' is the name of that element and in 'sendKeys()' we have to specify the absolute path of the content that we want to upload (that can be file/image/video etc).
Sample HTML Code should look similar to this :
With the help of AutoIt tool (open source tool) we can upload by transferring the control from Selenium webdriver to AutoIt.
We need to explicitly call the AutoIt script from our program.
About AutoIT : AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting.
We need to call the AutoIt script after clicking on the upload button. Immediately after clicking on Upload button, the control should be transferred to AutoIt by the below statement which takes care of uploading the file.
There are different ways to handle file uploads with Selenium Webdriver.
The First and the Easy way is simple case of just finding the element and typing the absolute path of the document into it.
HTML code should look similar to this :
<input type="file" name="datafile">