2015-09-10 33 views
2

我无法在Robot Framework中使用Selenium2Library。它引发以下错误:无法在Robot Framework中使用Selenium2Library。 ImportError:没有名为Selenium2Library的模块错误

C:\RFW>jybot.bat SW_Installation.robot 
[ ERROR ] Error in file 'C:\RFW\SW_Installation.robot': Importing test library ' 
Selenium2Library' failed: ImportError: No module named Selenium2Library 
Traceback (most recent call last): 
    None 
PYTHONPATH: 
    C:\RFW\SWInstall.sikuli 
    C:\RFW\robot\libraries 
    C:\RFW 
    C:\RFW\sikulixapi.jar\Lib 
    C:\RFW\Lib 
    C:\RFW\jython-standalone-2.7-b3.jar\Lib 
    __classpath__ 
    __pyclasspath__/ 
    . 
CLASSPATH: 
    C:\RFW\jython-standalone-2.7-b3.jar 
    C:\RFW\sikulixapi.jar 

我的机器人文件是:

***Settings*** 

Library  Selenium2Library 
Library  Install.Installation WITH NAME Installation 

*** Variables *** 

${NONE}    none 


***Test Cases*** 


testcase1 
    ClickInstallBatFile 
    sleep   90 
    Click Button  885,523 

我曾尝试在Python交互shell导入库。它的工作如预期如下所示:

Microsoft Windows [Version 6.1.7600] 
Copyright (c) 2009 Microsoft Corporation. All rights reserved. 

C:\Users\test>python 
ActivePython 2.7.8.10 (ActiveState Software Inc.) based on 
Python 2.7.8 (default, Jul 2 2014, 19:50:44) [MSC v.1500 32 bit (Intel)] on win 
32 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import Selenium2Library 
>>> import SeleniumLibrary 
>>> 

任何人都可以提供任何线索吗?

感谢, 库马尔

+0

是的,你可以在python中导入库。但是你使用的是不关心你的python库的jybot。 –

+0

这可能是http://stackoverflow.com/q/29369339/7432的副本 –

回答

2

看起来您已经为python安装了Selenium2Library,但是您正在使用jython(通过jybot)来运行您的测试。

你至少有三种解决方案:

  1. 开关pybot。您仍然可以使用基于java的关键字jrobotremoteserver

  2. 使用jython进行安装。欲了解更多信息,请参阅此问题:Can I install Selenium2Library for RobotFramework without installing Python?

  3. 使用port of Selenium2Library来java。

+1

解决方案编号3为我工作。谢谢你的帮助。 – Kumar

0

对于一个普通的Java解决方案,看here

从我记得它的工作,如果你添加所有必需的罐子到你的类路径。但是我删除了我的jython,所以我无法验证。

无论如何,我建议使用pybot而不是jybot。

相关问题