How to handle File Upload in Robot Framework

喜夏-厌秋 提交于 2019-12-08 05:13:08

问题


I have excel importer in my application when I click on the "Upload" button I will get a pop up window with file upload screen where I can select the excel from the specified path. How to handle this in Robot Framework? Can any one help me how to handle the case?


回答1:


Selenium2Library provides Choose File keyword for the same.

It takes two arguments, first is locator for the button and second is path to the file which needs to be uploaded.

e.g.

Choose File xpath=.//div/input  ${TEMPDIR}${/}file_pa.csv



回答2:


If you're using a dialog or input that WebDriver can interact with, then Sachin's answer about Choose File is the way to go.

If you're talking about the pre-HTML5 file-chooser dialogs provided by the browser, then Selenium2Library can't do this. However RobotFramework isn't just a wrapper around Selenium2Library so you can use something else that allows you to interact with the file upload screen.

I've done it in the past using AutoIt.

If you're not explicitly testing the upload dialog (and why should you, since it's provided as an atomic widget by your browser) then you should consider ways to simply avoid it. Perhaps a simple rest interface for uploading files.



来源:https://stackoverflow.com/questions/26360580/how-to-handle-file-upload-in-robot-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!