【发布时间】:2017-11-18 21:13:35
【问题描述】:
我正在为我的 Web 应用程序使用 Robot Framework 和 Selenium 编写测试用例。我试图上传一个文件,但我不能失败。
我的代码是
*** Variables ***
${TVAURL} http://localhost:1500/
${Browser} Firefox
TC_01: Enter into the application
[Documentation] Enter into the application to upload a file
Open Browser ${TVAURL} ${Browser}
maximize browser window
Choose File ........
HTML 文件:
<!DOCTYPE html>
<html>
<head>
<title>Upload File</title>
</head>
<body>
<form action="upload.php" method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit">
</form>
</body>
</html>
我需要知道如何使用此 Choose File 进行此文件上传测试。我不知道该怎么做。我需要自动上传文件,无需任何第三方工具,如 Autoit 等,
我参考了以下http://robotframework.org/Selenium2Library/Selenium2Library.html#Choose%20File
此外,我也提到了以下问题
- File Upload Option in Automation Testing Using Robot Framework
- https://github.com/robotframework/OldSeleniumLibrary/issues/108
但我找不到任何解决方案。请帮助我如何使用机器人框架,Pycharm Studio 中的 Selenium 来做到这一点。
回复答案 #1:@demouser123
我还是有问题,这里我附上了屏幕截图
它总是打开桌面,但失败了。请帮助我。
我试过下面的代码
*** Variables ***
${PO_AddShell} //*[@id="fileToUpload"]
click button ${PO_AddShell}
Choose File ${PO_AddShell} E://Project/Publish/SampleTest.1500/rose.jpg
【问题讨论】:
-
当你说“它失败了”时,请说明错误。
-
@demouser123 - 我不知道如何指定命令。
标签: selenium pycharm robotframework filechooser selenium2library