简体   繁体   English

如何使用机器人框架从文件浏览器中选择PC中的文件?

[英]How can I select files from PC in the file explorer using robot framework?

I have a button for Import which when clicked opens the windows file explorer from which we should select an excel file, which will then be imported. 我有一个Import按钮,当点击它打开windows文件浏览器时,我们应该从中选择一个excel文件,然后导入该文件。 I cannot use seleniumlibrary since it has windows automation as well. 我不能使用seleniumlibrary,因为它也有windows自动化。 I have the autoIT library, but how can i use it on a web page already brought open by selenium2library? 我有autoIT库,但是如何在已经由selenium2library打开的网页上使用它?

Try "Choose File" Keyword in SeleniumLibrary. 在SeleniumLibrary中尝试“选择文件”关键字。

You can find the details in below link http://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Choose%20File 您可以在以下链接中找到详细信息http://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Choose%20File

So, after many trials, The choose File worked. 因此,经过多次试验,选择文件工作。 It should be noted that choose file keyword accepts only an input type locator to it. 应该注意的是,select file关键字只接受输入类型定位器。 The tag my element had was button. 我元素的标签是按钮。 In my case however there was a hidden input element. 在我的情况下,有一个隐藏的输入元素。 It seems that in cases where file upload happens, an input type element has to be given in my application. 似乎在发生文件上传的情况下,必须在我的应用程序中给出输入类型元素。

Choose file  //input[@hidden='true']  mypathToExcel

The above code worked for me where mypathToExcel is the path to my excel file. 上面的代码适用于我,其中mypathToExcel是我的excel文件的路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM