简体   繁体   English

使用 Robot Framework 的自动化测试中的文件上传选项

[英]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.

相关问题 使用Robot Framework Test在浏览器中上传文件 - Upload a file in browser using Robot Framework Test 如何使用 Robot Framework 在自动化测试中更改 Gitlab 中 CI/CI 的 URL - How to change URL from CI/CI in Gitlab on Automation Testing using Robot Framework 如何使用自动化(机器人框架等)启动Chrome扩展程序 - How to launch Chrome Extension using Automation (Robot Framework, etc.) 用于系统测试的机器人框架 - robot framework for system testing WebDriverException:消息:找不到文件-关闭Robot Framework中的Upload File窗口 - WebDriverException: Message: File not found - Close Upload FIle window in Robot Framework 选择文件成功执行但没有在机器人框架中上传文件 - Choose File executes successfully but does not upload file in Robot Framework 无法使用机器人 class 和 Sendkeys 上传文件 - Not able to upload file using robot class and Sendkeys 您可以使用Robot Framework进行跨浏览器测试吗 - Can you have cross browser testing using Robot Framework 在机器人框架中设置默认文件上传文件夹(目录) - Setting default file upload folder (directory) in robot framework 机器人框架测试自动化硒 - Robot-Framework-Test-Automation selenium
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM