首页 文章

如何检查selenium2library是否已添加到RIDE中的robotframework项目中

提问于
浏览
1

我是Robot Framework的新手

我正在使用 RIDE 1.5.2.1Python 2.7.13 上运行 . 在我的机器上安装Python后,我执行了以下操作,以安装Selenium2Library:

python -m pip install robotframework-selenium2library

而这似乎已将其安装到路径:

C:\Python27\Lib\site-packages

现在,我想将selenium2library添加到RIDE中的robotframework项目中,但是我找不到该文件 .

以下是我的测试套件:

*** Settings ***
Library           selenium2library

*** Test Cases ***
User can load the landing page
    [Documentation]    User opens the landing page
    Open Browser    http://localhost:8080/    ie
    Close Browser

但它失败了这个错误:

[ ERROR ] Error in file 'C:\Python27\Scripts\Customer\Landing_Page\Landing_Page.txt': Importing test library 'selenium2library' failed: ImportError: No module named selenium2library
Traceback (most recent call last):
    Traceback (most recent call last):
      None
    PYTHONPATH:
      C:\Windows\SYSTEM32\python27.zip
      C:\Python27\DLLs
      C:\Python27\lib
      C:\Python27\lib\plat-win
      C:\Python27\lib\lib-tk
      C:\Python27
      C:\Python27\lib\site-packages
      C:\Python27\lib\site-packages\robotframework-3.0-py2.7.egg
      C:\Python27\lib\site-packages\decorator-4.0.10-py2.7.egg
      C:\Python27\lib\site-packages\robotframework_selenium2library-1.8.0-py2.7.egg
      C:\Python27\lib\site-packages\selenium-3.0.2-py2.7.egg
      C:\Python27\lib\site-packages\pygments-2.1.3-py2.7.egg
      C:\Python27\lib\site-packages\wx-2.8-msw-unicode
    Customer                                                           | FAIL |
    1 critical test, 0 passed, 1 failed
    1 test total, 0 passed, 1 failed

看来,它没有找到Selenium2library`,但是当我再次尝试安装时,它说:

Requirement already satisfied: robotframework-selenium2library in c:\pytho
b\site-packages
Requirement already satisfied: decorator>=3.3.2 in c:\python27\lib\site-pa
 (from robotframework-selenium2library)
Requirement already satisfied: selenium>=2.32.0 in c:\python27\lib\site-pa
 (from robotframework-selenium2library)
Requirement already satisfied: robotframework>=2.6.0 in c:\python27\lib\si
kages\robotframework-3.0-py2.7.egg (from robotframework-selenium2library)

我很困惑,似乎我已经有了selenium2library,但是RIDE找不到了吗?

3 回答

  • 5

    添加项目级别和套装级别等地点 .

    SeleniumLibrary或Selenium2Library

    只在“名称”字段中输入并按确定 . 如果它安装在python文件夹中,它会自动添加 .

    enter image description here

    enter image description here

  • 3

    请按照本网站上的说明进行操作https://github.com/robotframework/RIDE/wiki/Installation-Instructions

    与PIP一起安装后 - https://github.com/robotframework/robotframework/blob/master/INSTALL.rst#installing-with-pip

    您可以使用'pip freeze'命令检查已安装的库版本

    还要确保使用python安装文件夹和脚本文件夹更新PATH变量

    一旦您知道安装了所有必需的库,就可以导入selenium库

    *** Settings ***
        Documentation     A test suite with a single test for valid login.
        Library           Selenium2Library
        ...
    
  • 0

    您导入了错误的库名称(小写) .

    导入测试库'selenium2library'失败:ImportError:没有名为selenium2library的模块

    正确的import语句是:

    Library           Selenium2Library
    

    在测试套件的设置部分的RIDE上,您会看到红色的“selenium2library”,更正后的黑色 .

相关问题