Kumar
Kumar

Reputation: 717

Unable to use Selenium2Library in Robot Framework. ImportError: No module named Selenium2Library error

I am unable to use Selenium2Library in Robot Framework. It throws the following error:

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

My Robot file is:

***Settings***

Library     Selenium2Library
Library     Install.Installation  WITH NAME  Installation

*** Variables ***

${NONE}             none


***Test Cases***


testcase1
    ClickInstallBatFile
    sleep           90
    Click Button        885,523

I have tried importing the Library in the python interactive shell. Its working as expected as shown below:

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

Could anyone give any clue please?

Thanks, Kumar

Upvotes: 2

Views: 4302

Answers (2)

Bryan Oakley
Bryan Oakley

Reputation: 385920

It appears you have installed Selenium2Library for python, but you are using jython (via jybot) to run your tests.

You have at least three solutions:

  1. switch to pybot. You can still use java-based keywords via the jrobotremoteserver

  2. Install it with jython. For more information see this question: Can I install Selenium2Library for RobotFramework without installing Python?

  3. Use the port of Selenium2Library to java.

Upvotes: 2

Würgspaß
Würgspaß

Reputation: 4820

For a plain Java solution, look here.

From what I remember it worked, if you add all required jars to your classpath. But I have removed my jython, so I cannot verify.

In any way, I recommend using pybot instead of jybot.

Upvotes: 0

Related Questions