RobotFramework+seleniumlibrary Web自动化测试 (三)

考虑到selenium2的功能更为完善,为避免后续可能出现的问题,计划将seleniumlibrary 升级为 selenium2library,

相比SeleniumLibrary,Selenium2Libarary的优势如下:

1.由于将通过起Server然后向浏览器注入JS,通过JS引擎操纵浏览器的方式改为了直接操纵浏览器接口的方式,Selenium2Library速度有了显著提升,稳定性也得到了进一步加强。

2.能够越过浏览器沙箱操控其它资源,比如:文件上传,弹出的windows窗体等。

3.因为底层的webdriver使用blocking Api( 页面请求发出后,浏览器等待结果的返回,其间不能做后续操作),那些恶心的wait和don’t wait 参数就可以扔掉了。

如果你用windows: 

https://github.com/rtomac/robotframework-selenium2library/downloads

在上面页面上下载对应的安装包,一路点击next就安装好了。后面的命令行安装方式可以略过。

————————————————————————

Github下载:

https://github.com/rtomac/robotframework-selenium2library

可以直接下载zip文件,也可以用svn工具下载源码。

在命令行模式进入下载好的文件目录(如果下载的是zip,解压到一个文件夹),执行setup.py install来安装。

如果提示错误,可能是你没有安装python的setuptools,先安装它再尝试上面步骤。

http://pypi.python.org/pypi/setuptools

另外有两个库是seleniuim2中必须的

easy_install decorator

easy_install docutils

验证安装是否成功:

Selenium2Library个出了一个很cool的验收测试。

我们使用它提供的验收测试就能查看是否安装成功,并且顺便测试了selenium2Library的测试。

我们可以在命令行进入它的Test子目录然后运行run_test.py python ie

这个脚本的作用其实是起了一个微型的webserver,然后用浏览器访问这个server,作为被测系统。

最后调用robotframework对这个被测系统进行测试。如果看到绝大部分pass了,说明你装好了。

新增的关键字:

  • Get Selenium Speed
  • Get Selenium Timeout
  • Log Title
  • Log Location

参数改变的关键字

  • Choose File – Pulled remote files support
  • Click Button – Removed dont_wait argument
  • Click Element – Removed dont_wait and coordinates arguments
  • Click Image – Removed dont_wait argument
  • Click Link – Removed dont_wait argument
  • Double Click Element – Removed dont_wait and coordinates arguments
  • Go Back – Removed dont_wait argument
  • Open Context Menu – Removed offset argument
  • Press Key – Removed dont_wait argument
  • Select All From List – Removed wait argument
  • Select Radio Button – Removed wait argument
  • Submit Form – Removed dont_wait argument

移除的关键字

  • Flex-related keywords
  • Add Location Strategy
  • Call Selenium API
  • Capture Screenshot (better support for Capture Page Screenshot in Selenium 2/WebDriver, and conversely no support for full screen screenshot)
  • Drag And Drop (requires Advanced User Interactions API which isn’t quite ready to support this)
  • Press Key Native (requires Advanced User Interactions API which isn’t quite ready to support this)
  • Start Selenium Server
  • Stop Selenium Server
  • Wait Until Page Loaded (Selenium 2/WebDriver is blocking API, so this is not important/less important)

只可惜,我装完之后,除了两个case是pass外,其余都是fail。。。。出现了各种各样的问题:

1. 使用firefox时候,报TypeError: environment can only contain strings

   解决办法:(待补充)

2. 使用IE时候,报WebDriverException: Message: 'IEDriver executable needs to be available in the path.

   解决办法:官网http://code.google.com/p/selenium/downloads/list下载对应IEDriver.exe,并将其放在python目录下

3. 重装后执行pybot提示:

'"[PYTHON_EXECUTABLE]"' is not recognized as an internal or external command, operable program or batch file.
查看环境变量设置正确,重新安装无效。搜索robotframework的issue库。有下面解决方法:
在python的script文件夹下找到robot_postinstall.py这个文件执行以下就解决问题了。
出现这种情况的条件是:win7,原有2.6.3版本没有卸载干净,然后装了2.7.4版本。
这是issue列表中的帖子链接: http://code.google.com/p/robotframework/issues/detail?id=810
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值