robotframework接口自动化-批量上传文件

robotframework接口自动化-批量上传文件,第1张

接口自动化庆派芹中自然不能少的了上传文件,但是上传文件好多同学不太清楚誉毕怎么去做,我这里羡让做一个批量上传的接口,同样也支持单个上传。

首先我们找一个支持文件上传的接口,或者自己写一个(有开发能力可动手实现 . )

我使用的接口如下:

下面我们开始写上传文件的RF脚本

之后,我们可以这样使用

choose file

官方给定的解释如下:

Source:

Selenium2Library <洞亏test library>

Arguments:

[ locator | file_path ]

Inputs the `file_path` into file input field found by `identifier`.

This keyword is most often used to input files into upload forms. The

file specified with `file_path` must be available on the same host where

the Selenium Server is running.

Example:

Choose File my_upload_field /home/user/files/trades.csv

一开始以为进入到上传页面,点击浏览,再使用choose file,结果发现,这个函数包含了 点击浏览--选中文件 那么点击浏览就是多余的 *** 作了

在该页面,就只需要执行choose 就可以将图片选中,执行的具体命令为:

choose filexpath=//div[@class='纳郑神pd6 dot fcb']/span/input

C:\\Documents and Settings\\zhouxuan\\My Documents\\My

Pictures\\bug5.png

其中xpath为选中浏览图标的路径,而 C:\\Documents and Settings\\zhouxuan\\My Documents\\My Pictures\\bug5.png(此处的\\为转义用,当只用\时会出现错误)则为需要上传的图片丛兄的路径。

该 *** 作执行完毕后,则会显示为:

图片已经顺利加载进来了,后续的 *** 作就很简单了。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/12300988.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存