2
votes

I am very new to Robot Framework

I am using RIDE 1.5.2.1 running on Python 2.7.13. After I installed Python on my machine, I executed the following, to install the Selenium2Library:

python -m pip install robotframework-selenium2library

and that seems to have installed it to the path:

C:\Python27\Lib\site-packages

Now, I would like to add selenium2library to my robotframework project within RIDE, but I can't find the file.

Below is my Test Suite:

*** 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

But it fails with this error:

[ 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

It seems that, it does not find the Selenium2library`, but when I try to install it again it says:

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)

I am confused, it seems that I already have selenium2library, but RIDE cannot find it?

3

3 Answers

7
votes

Please follow the instructions on this site https://github.com/robotframework/RIDE/wiki/Installation-Instructions

Once you install this along with PIP - https://github.com/robotframework/robotframework/blob/master/INSTALL.rst#installing-with-pip

you can check the installed versions of the libraries using 'pip freeze' command

Also make sure that you update PATH variable with python installed folder and Script folder

once you know that all the required libraries are installed you can import selenium library

    *** Settings ***
    Documentation     A test suite with a single test for valid login.
    Library           Selenium2Library
    ...
3
votes

You imported the wrong name of the library (lower case).

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

The correct import statement is:

Library           Selenium2Library

On RIDE on setting section of the Test Suite, you would see "selenium2library" in red color, and in black after corrected.

0
votes

Add both the places like project level & Suit level.

SeleniumLibrary or Selenium2Library

only type on the "Name" field & press ok . it will automatically add if it is installed on python folder.

enter image description here

enter image description here