0

I cant not add Selenium2Library, i get this error (import file not found)

*** Settings ***
Documentation     Simple example using SeleniumLibrary.
Library           Selenium2Library
4
  • The Selenium2Library is old. Try installing robotframework-seleniumlibrary and then using SeleniumLibrary in your settings. Commented Oct 21, 2019 at 16:02
  • I have this on pip list : robotframework-selenium2library 1.8.0 robotframework-seleniumlibrary 4.1.1.dev1 Commented Oct 21, 2019 at 18:15
  • You don't need both. You should remove robot-selenium2library 1.8.0. that is over 3 years old. Commented Oct 21, 2019 at 18:18
  • i have this : !Valid XHTML. Commented Oct 21, 2019 at 18:29

4 Answers 4

1

Make sure you have Selenium2Library installed by using

pip list

In case Selenium2Library is not displayed in the list, then download the library by using:

pip install --upgrade robotframework-selenium2library

I assume you have pip installed, If not this is the procedure:

  1. Download get-pip.py to a folder on your computer.
  2. Open a command prompt and navigate to the folder containing get-pip.py.
  3. Run the following command: python get-pip.py
Sign up to request clarification or add additional context in comments.

Comments

1

Try installation as above @Alberto below or visit for installation documentation

SeleniumLibrary documents says also following:

NOTE: Selenium2Library has been renamed to SeleniumLibrary since version 3.0. Nowadays Selenium2Library is just a thin wrapper to SeleniumLibrary that eases with transitioning to the new project. See SeleniumLibrary and Selenium2Library project pages for more information.

Comments

0

have you installed the selenium2library library? If not, try installing it with this command:

pip install robotframework-selenium2library

Comments

0

Please verify whether you have performed the following before executing your code.

BEFORE - robotframework-selenium2library is installed

(myblog) 05:53 PM##~/bins/projects/PycharmProjects/blog::>conda activate rf1
(rf1) 05:54 PM##~/bins/projects/PycharmProjects/blog::>pip list
Package                 Version            
----------------------- -------------------
certifi                 2018.11.29         
chardet                 3.0.4              
colorama                0.4.1              
configparser            4.0.2              
crayons                 0.3.0              
et-xmlfile              1.0.1              
idna                    2.8                
jdcal                   1.4.1              
openpyxl                3.0.1              
pip                     19.3.1             
robotframework          3.1.2              
robotframework-excellib 2.0.0              
setuptools              41.6.0.post20191030
wheel                   0.33.6             

AFTER - robotframework-selenium2library is installed, notice that 3 packages are installed,eventhough you have just installed one package,

robotframework-selenium2library, robotframework-seleniumlibrary,selenium

(rf1) 05:54 PM##~/bins/projects/PycharmProjects/blog::>pip install robotframework-selenium2library
Collecting robotframework-selenium2library
  Downloading https://files.pythonhosted.org/packages/1c/f1/612f9aa29f33b25a1034749dde67dfbf6de9b297709d06df71f9bfabfc81/robotframework_selenium2library-3.0.0-py2.py3-none-any.whl
Collecting robotframework-seleniumlibrary>=3.0.0
  Using cached https://files.pythonhosted.org/packages/dc/69/c20102b9e336b32eb813966ee2b98b6de1b1249032ebb3ce3cabcf26fac7/robotframework_seleniumlibrary-4.1.0-py2.py3-none-any.whl
Collecting selenium>=3.8.1
  Using cached https://files.pythonhosted.org/packages/80/d6/4294f0b4bce4de0abf13e17190289f9d0613b0a44e5dd6a7f5ca98459853/selenium-3.141.0-py2.py3-none-any.whl
Requirement already satisfied: robotframework>=3.0.4 in /Users/apachemain/bins/anaconda/envs/rf1/lib/python3.7/site-packages (from robotframework-seleniumlibrary>=3.0.0->robotframework-selenium2library) (3.1.2)
Collecting urllib3
  Using cached https://files.pythonhosted.org/packages/b4/40/a9837291310ee1ccc242ceb6ebfd9eb21539649f193a7c8c86ba15b98539/urllib3-1.25.7-py2.py3-none-any.whl
Installing collected packages: urllib3, selenium, robotframework-seleniumlibrary, robotframework-selenium2library
Successfully installed robotframework-selenium2library-3.0.0 robotframework-seleniumlibrary-4.1.0 selenium-3.141.0 urllib3-1.25.7
(rf1) 05:54 PM##~/bins/projects/PycharmProjects/blog::>pip list
Package                         Version            
------------------------------- -------------------
certifi                         2018.11.29         
chardet                         3.0.4              
colorama                        0.4.1              
configparser                    4.0.2              
crayons                         0.3.0              
et-xmlfile                      1.0.1              
idna                            2.8                
jdcal                           1.4.1              
openpyxl                        3.0.1              
pip                             19.3.1             
robotframework                  3.1.2              
robotframework-excellib         2.0.0              
robotframework-selenium2library 3.0.0              
robotframework-seleniumlibrary  4.1.0              
selenium                        3.141.0            
setuptools                      41.6.0.post20191030
urllib3                         1.25.7             
wheel                           0.33.6             
(rf1) 05:54 PM##~/bins/projects/PycharmProjects/blog::>

CODE


*** Settings ***
Documentation     This example demonstrates how to use current library
Library      Selenium2Library

*** Test Cases ***
Run Sample Selenium Case
    Open Browser   http://google.com
    Set Window Size    1920    1080
    ${title}=    Get Title
    Should Be Equal    Google    ${title}
    [Teardown]    Close Browser

OUTPUT


(rf1) 06:02 PM##~/bins/projects/PycharmProjects/blog::>robot sam.robot 
==============================================================================
Sam :: This example demonstrates how to use current library                   
==============================================================================
Run Sample Selenium Case                                              | PASS |
------------------------------------------------------------------------------
Sam :: This example demonstrates how to use current library           | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
Output:  /Users/apachemain/bins/projects/PycharmProjects/blog/output.xml
Log:     /Users/apachemain/bins/projects/PycharmProjects/blog/log.html
Report:  /Users/apachemain/bins/projects/PycharmProjects/blog/report.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.