【问题标题】:Unable to use Selenium2Library in Robot Framework. ImportError: No module named Selenium2Library error无法在 Robot Framework 中使用 Selenium2Library。 ImportError:没有名为 Selenium2Library 的模块错误
【发布时间】:2015-12-06 17:11:09
【问题描述】:

我无法在 Robot Framework 中使用 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
>>>

谁能给点线索?

谢谢, 库马尔

【问题讨论】:

标签: python robotframework


【解决方案1】:

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

您至少有三个解决方案:

  1. 切换到 pybot。您仍然可以通过 jrobotremoteserver

  2. 使用基于 java 的关键字
  3. 使用 jython 安装它。有关更多信息,请参阅此问题:Can I install Selenium2Library for RobotFramework without installing Python?

  4. 在java中使用port of Selenium2Library

【讨论】:

  • 解决方案 3 对我有用。感谢您的帮助。
【解决方案2】:

对于简单的 Java 解决方案,请查看 here

据我所知,如果您将所有必需的 jar 添加到类路径中,它会起作用。但是我已经删除了我的 jython,所以我无法验证。

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

【讨论】:

    猜你喜欢
    • 2017-11-14
    • 2021-06-04
    • 2015-08-12
    • 2020-02-17
    • 2017-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-05
    相关资源
    最近更新 更多