Question

When I try to import python Library in RIDE (robot framework IDE), it fails because the library imports java.lang.

The RIDE Log shows the following error:

Importing test library '../libraries/ExampleLibrary.py' failed: ImportError: No module named java.lang

Here is the sample test case to multiply written for robot frame work

*** Settings ***
 Library           ../libraries/ExampleLibrary.py
 Library           ../libraries/NorthboundLibrary.py

*** Test Cases ***
 Hello World
    Log    Hello, World!

 Multiply Test
    Multiply Me    8    8

Method defined in the ExampleLibrary.py

../libraries/ExampleLibrary.py

 import os
 import sys

 from java.lang import Math
 from com.cisco.csdn.tifmgr import TIFConfig

 def multiply_me(first, second):
    print '*DEBUG* Got arguments %s and %s' % (first, second)
    return float(first) * float(second)

RIDE failed to load the ExampleLibrary.py

No correct solution

OTHER TIPS

Why are you importing

from java.lang import Math
from com.cisco.csdn.tifmgr import TIFConfig

?

In the code you showed you are not using them.

Also why are you importing a Java class in Python ?

Just remove these two lines and you'd be fine.

RIDE executes in CPython, not inside a JVM, and therefore has no way understand Java or Jython code. Your example code is Jython and will not work in CPython. If you want the help and auto-completion that RIDE provides, you should create spec files for your libraries using libdoc and make sure RIDE can find them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top