如何使用Hybrid library API来定制Selenium2Library

123 views
Skip to first unread message

Hideo

unread,
Jun 13, 2013, 5:43:08 AM6/13/13
to robotfra...@googlegroups.com

大家好:
 
最近在考虑自己写定制库来调用Selenium2Library。
目的是为了重写Selenium2Library中的一些方法。
 
准备使用Hybrid library API的方式来书写自定义库。
在__getattr__方法中处理调用Selenium2Library的工作,
即在自定义库中不涉及任何调用Selenium2Library的方法,
当检测到要调用的方法在自定义库中不存在时,
执行__getattr__方法中的内容,
返回Selenium2Library的方法对象。
 
下面是部分代码。
 
from Selenium2Library import Selenium2Library
 
    def __init__(self, timeout=5.0, implicit_wait=0.0, run_on_failure='Capture Page Screenshot'):
        global selenium2lib
        selenium2lib = Selenium2Library(timeout, implicit_wait, run_on_failure)
 
    def __getattr__(self, name):
        return getattr(selenium2lib, name)
 
试运行后发现可以正常进行打开浏览器,点击按钮,输入文字等操作,
但是唯独关闭浏览器的操作不能正常完成。
以下为出错信息:
20130613 17:31:17.028 :  FAIL : No browser is open
20130613 17:31:17.028 :  WARN : Keyword 'Capture Page Screenshot' could not be run on failure: No browser is open
20130613 17:31:17.028 :  FAIL : AttributeError: can't set attribute
 
 
想请教各位,不能正常关闭浏览器的原因 在哪里。

Xu Yi

unread,
Jun 14, 2013, 3:44:14 AM6/14/13
to robotfra...@googlegroups.com
试运行具体都运行了一些啥?


--
您收到此邮件是因为您订阅了 Google 网上论坛的“robotframework-cn”论坛。
要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到 robotframework...@googlegroups.com
要向此网上论坛发帖,请发送电子邮件至 robotfra...@googlegroups.com
要在网络上查看此讨论,请访问 https://groups.google.com/d/msgid/robotframework-cn/5890489c-8da2-4cf9-9dc4-aa29dd8737ba%40googlegroups.com?hl=zh-CN。
要查看更多选项,请访问 https://groups.google.com/groups/opt_out。
 
 



--
- - - - - - - - - -
Xu Yi, Kaverjody
Blog : http://kaverjody.com
Sina Weibo : http://weibo.com/kaverjody
Skype : kaverjody
- - - - - - - - - -

李英杰

unread,
Jun 14, 2013, 4:01:14 AM6/14/13
to robotfra...@googlegroups.com

感谢回信!
现在已经查明原因,是由于RobotFramework最新版2.8和Selenium2Library不兼容所致。
开发者预定发布2.81版本解决这个问题。

2013/06/14 15:44 "Xu Yi" <kave...@gmail.com>:
--
您收到此邮件是因为您订阅了 Google 网上论坛“robotframework-cn”中的主题。
要退订此主题,请访问 https://groups.google.com/d/topic/robotframework-cn/YzBFAqcA3WE/unsubscribe。
要退订此论坛及其所有主题,请发送电子邮件到 robotframework...@googlegroups.com
要向此网上论坛发帖,请发送电子邮件至 robotfra...@googlegroups.com
要在网络上查看此讨论,请访问 https://groups.google.com/d/msgid/robotframework-cn/CAL41vZDwQv_XsD%2Bsi3xrvp%2BaVTHHtZ43WvN-P4bUgif3kH8iaQ%40mail.gmail.com。
要查看更多选项,请访问 https://groups.google.com/groups/opt_out。
 
 
Reply all
Reply to author
Forward
0 new messages