如何在RIDE中检查selenium2库是否添加到robotframework项目中

2024-06-01 06:47:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我对机器人框架很陌生

我正在使用RIDE 1.5.2.1运行于Python 2.7.13。 在我的机器上安装了Python之后,我执行了以下步骤来安装selenium2库:

python -m pip install robotframework-selenium2library

似乎已经安装到路径上了:

C:\Python27\Lib\site-packages

现在,我想在RIDE中将selenium2库添加到我的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

它似乎找不到selenium2库,但当我再次尝试安装它时,它说:

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)

我很困惑,好像我已经有了赛琳娜2的图书馆,但是骑行找不到了吗?


Tags: intestegglibpackagessiterequirementrobotframework
3条回答

添加两个位置,如项目级别和西装级别。

SeleniumLibrary或Selenium2库

仅在“名称”字段上键入并按“确定”。如果安装在python文件夹上,它将自动添加。

enter image description here

enter image description here

请按照本网站上的说明操作 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
    ...

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

Importing test library 'selenium2library' failed: ImportError: No module named selenium2library

正确的导入语句是:

Library           Selenium2Library

在测试套件的骑行设置部分,您将看到红色的“selenium2library”,更正后将看到黑色的“selenium2library”。

相关问题 更多 >