How to handle File Upload in Robot Framework

拟墨画扇 提交于 2019-12-08 02:54:15
Sachin Nikam

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

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.

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