问题描述
我正在使用 Google 的 Robot Framework 和 SeleniumLibrary(一个测试库)编写用于 Web 测试的机器人测试,其中一项测试涉及通过单击网页上的浏览"按钮并使用 Windows 文件从桌面上传文件弹出来导航并选择文件的资源管理器窗口(出于安全原因,在网站上禁用了文件的文本路径.)我试过四处挖掘,但发现很少自动执行此 Windows 文件资源管理器操作,有没有办法让我可以吗?
I am writing robot tests for web testing using Google's Robot Framework with SeleniumLibrary (a test library) , one of my test involves uploading a file from the desktop by clicking on a"Browse" button on the webpage and using the windows file explorer window that pops up to navigate to and select the file ( providing a text path to file is disabled on the website for security reasons.) I have tried digging around but found little on automating this Windows File Explorer action , is there a way I can do this ?
下载 AutoIt 库并尝试安装后,要求 wincom32./python 窗口扩展.我正在尝试安装它时出现一些错误,例如
After downloading the AutoIt library and trying to install it is asking for wincom32./python window extensions.And i am trying to install it is giving some error like
Building pywin32 2.7.217.0
Trace-back (most recent call last):
File "setup.py", line1944, in <module>
""" % dirs).split(),
File "setup.py", line 603, in __init__
if os.path.isfile(os.path.join(sdk_dir, "include", "activdbg.h")):
File"C:\Python27\lib\ntpath.py", line 96 in join
assert len(path) > 0
TypeError: object of type 'NoneType' has no len()
推荐答案
以下是在 Windows 中为机器人框架安装 autoit 的快速分步指南(因为在 python 中使用什么版本很痛苦):
Below is a quick step to step guide to install autoit for robotframework in Windows (as what versions work with what in python is a pain):
首先,您需要一个 32 位的 python,因为 Windows 64 位系统不会安装 autoit.我用过:
First you will need a 32 bit python as autoit will not install for windows 64bit. I have used:
- Python 2.6
然后从 http://sourceforge.net/projects/pywin32/files/pywin32/Build%20217/下载 Windows 安装程序,因此对于 python 2.6,它将是:
Then from http://sourceforge.net/projects/pywin32/files/pywin32/Build%20217/Download the windows installer so for python 2.6 it will be:
- pywin32-217.win32-py2.6.exe
现在在命令提示符下转到您下载 autoit 文件的位置,例如:- cd C:\Development\Downloaded files\AutoItLibrary-1.1然后输入- python setup.py install
Now on the command prompt go to the location of where you downloaded the autoit files ex: - cd C:\Development\Downloaded files\AutoItLibrary-1.1and then type - python setup.py install
如果成功,您将在 cmd 行中看到如下几行:
If successful you will see lines in the cmd line such as:
Generating...
Importing module
running install
running build
running build_py
creating build
creating build\lib
creating build\lib\AutoItLibrary
copying src\AutoItLibrary\Counter.py -> build\lib\AutoItLibrary
copying src\AutoItLibrary\Logger.py -> build\lib\AutoItLibrary
copying src\AutoItLibrary\__init__.py -> build\lib\AutoItLibrary
running install_lib
copying build\lib\AutoItLibrary\Counter.py -> C:\Python26\Lib\site- packages\AutoItLibrary
copying build\lib\AutoItLibrary\Logger.py -> C:\Python26\Lib\site-
现在运行测试C:\RobotFramework\Extensions\AutoItLibrary\tests
Now run the testC:\RobotFramework\Extensions\AutoItLibrary\tests
注意:确保您已正确设置环境变量:即- c:\python26 for python- c:\python26\pybot 脚本
Note: Ensure you have the environment variables set correctly:i.e. - c:\python26 for python - c:\python26\scripts for pybot
您现在可以通过创建一个 exe 并调用来运行您的机器人框架测试- 运行 C:\RobotFramework\Seans Autoit Files\FF_FileUpload.exe
You can now run your robotframework tests by creating an exe and calling - Run C:\RobotFramework\Seans Autoit Files\FF_FileUpload.exe
要了解如何创建 autoit exe,请访问 autoit 网站.
To find how to create the autoit exe visit the autoit website.
这篇关于安装 Autolit 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!