[英]File Upload Option in Automation Testing Using Robot Framework
I need to test a particular scenario where I need to upload a file from any folder from my local machine and check whether it gets uploaded correctly as that of below image.我需要测试一个特定的场景,我需要从本地机器的任何文件夹上传文件,并检查它是否像下图那样正确上传。 I am writing automation testing script using Robot Framework to test in Chrome browser我正在使用 Robot Framework 编写自动化测试脚本以在 Chrome 浏览器中进行测试
I am trying to use Choose File Keyword which is normally used for this scenario.我正在尝试使用通常用于这种情况的选择文件关键字。
Test8 To upload a file from Local Drive
Open Browser http://localhost:35234/ chrome
Select From List By Index ${transmission drop down} 0
Choose File ${upload click1} ${CURDIR}${/}SampleFiles${/}Test.txt
First Line opens my application locally. First Line 在本地打开我的应用程序。 Second line selects File Upload option from drop down.第二行从下拉列表中选择文件上传选项。 ${transmission drop down}
holds the ID of the drop down. ${transmission drop down}
保存${transmission drop down}
的 ID。
Then I am using Choose File
Option.然后我使用Choose File
选项。 ${upload click1}
option holds the xpath value of Add Document
button And Test.txt file is available in the corresponding folder provided. ${upload click1}
选项保存Add Document
按钮的 xpath 值,Test.txt 文件位于提供的相应文件夹中。
I am not sure where I am going wrong, but I am getting a strange webdriver error:我不确定我哪里出错了,但我收到了一个奇怪的 webdriver 错误:
WebDriverException: Message: u'unknown error: cannot focus element\n
(Session info: chrome=45.0.2454.93)\n (Driver info:chromedriver=2.15.322448
(52179c1b310fec1797c81ea9a20326839860b7d3),platform=Windows NT 6.1 SP1
x86_64)'
I am able to run other tests without this strange error.I am not sure whether the Choose File has right parameters.我能够在没有这个奇怪错误的情况下运行其他测试。我不确定选择文件是否有正确的参数。 Am I going wrong anywhere?我哪里出错了? It would be great if someone could help me by providing sample Test Case.如果有人可以通过提供示例测试用例来帮助我,那就太好了。
You say that ${upload click1}
has the xpath to an "add document" button.您说${upload click1}
具有“添加文档”按钮的 xpath。 The locator for Choose File
needs to be to an <input>
element on the page, not a button. Choose File
的定位器需要指向页面上的<input>
元素,而不是按钮。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.