I'm trying to make a test for the Upload file button of a web using robotframework but I can't find the way to do it.
Concretely, I'm using this web as a example:
http://www.zamzar.com/
And this is the properties of the upload button:
<input id="inputFile" class="bodyBig" type="file" name="file_1" size="12"
style="position: absolute; display: block; opacity: 0; z-index: 0;">
As I saw in the documentation, I'm using the Choose File but I get stucked in the Windows pop-up, it opens but file is not selected:
My testcase looks like this:
*** Settings ***
Suite Setup Test Setup Open Browser
Suite Teardown Test Teardown Close Browser
Resource SeleniumKeywords.tsv
*** Test Cases ***
Select file typing path
File Should Exist C:${/}Users${/}MADI${/}Desktop${/}image.bmp
Wait Until Page Contains Element id=inputFile
Choose File id=inputFile C:${/}Users${/}MADI${/}Desktop${/}image.bmp
Select From List toExtensionSel jpg
Input Text toEmail diego.mg.umh@gmail.com
Click Button uploadButton
Sleep 10
The file exists and it's in the correct location, do you know what do I need to change in order to get the file uploaded?
Thank you in advance, best regards.-
For uploading a file, you no need to worry about the windows popup. the Windows popup only appears when you upload a file manually.
So, when you are simulating the same via automation code use the following code format
choose file ${xpath} ${absolute_file_path}
Where Choose file is the Keyword which you have imported from selenium2libary, ${xpath} is the xpath of the upload file element in your case it is
xpath=//input[@id='inputFile']
And ${absolute_file_path} is the file path with file name from where you want to upload the file.
${absolute_file_path} C:\Users\MADI\Desktop\image.bmp
If you are using separate resource file to define the variable used in your code.
When you are clicking on "Choose File" button, a window is displayed which we can automate. So we have a couple of methods to overcome this issue.
Let me know if there is any issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.