Problem running robotframework-selenium2library-java

1,780 views
Skip to first unread message

yankovskya

unread,
Mar 3, 2014, 2:26:46 PM3/3/14
to robotframe...@googlegroups.com
Hello,

I'm having a problem with running my selenium webdriver tests using jybot either from RIDE or from command prompt. The same tests run with pybot. My understanding is that robot fails to use robotframework-selenium2library-java and instead uses python version robotframework-selenium2library. I've searched a lot for the solution and even followed the steps in "Encapsulate the robotframework-maven-plugin into a jybot-like script and execute from RIDE" posting. Then I was able to run my tests using selenium2library-java with maven plugin. So I've added the file robotframework-selenium2library-java-1.4.0.5-SNAPSHOT-jar-with-dependencies.jar that maven generated to the CLASSPATH, but still getting error running my tests with jybot:
[ ERROR ] Error in file 'C:\Users\...\Documents\Automation\Frameworks\RobotFramework\RF-Selenium2library-java\src\test\robotframework\testsuites\LoginTests\djx_resource.txt': Importing test library 'Selenium2Library' failed: SyntaxError: future feature unicode_literals is not defined (selenium.py, line 17)
Traceback (most recent call last):
  File "C:\Python27\Lib\site-packages\Selenium2Library\__init__.py", line 2, in <module>
    from keywords import *
  File "C:\Python27\Lib\site-packages\Selenium2Library\keywords\__init__.py", line 3, in <module>
    from _browsermanagement import _BrowserManagementKeywords
  File "C:\Python27\Lib\site-packages\Selenium2Library\keywords\_browsermanagement.py", line 4, in <module>
    from selenium import webdriver
  File "C:\Python27\Lib\site-packages\selenium\__init__.py", line 15, in <module>
    from selenium import selenium
PYTHONPATH:
  C:\Python27\Lib\site-packages\robot\libraries
  C:\Python27\Lib\site-packages
  C:\jython2.5.4rc1\Lib
  __classpath__
  __pyclasspath__/
  C:\jython2.5.4rc1\Lib\site-packages
  .
  C:\Python27\Scripts
CLASSPATH:
  C:\jython2.5.4rc1\jython.jar
  C:\Program Files (x86)\QuickTime\QTSystem\QTJava.zip
  C:\Users\yankovskya\Documents\Automation\Frameworks\RobotFramework\RF-Selenium2library-java\target\robotframework-selenium2library-java-1.4.0.5-SNAPSHOT-jar-with-dependencies.jar
RF-Selenium2library-java.Src.Test.Robotframework.Testsuites.LoginTests.Valid Login :: A test suite with...
==========================================================================================================
Valid Login                                                                                       | FAIL |
No keyword with name 'Open Browser' found.

Also teardown failed:
No keyword with name 'Close Browser' found.
...

I'm using RIDE 1.2.3, robotframework-2.8.3 running on (Python 2.7.6.and Jython 2.5.4rc1) and robotframework-selenium2library-java-1.4.0.4.  Could someone tell me what am I missing here please? Attached is my POM file for the reference.
 


pom.xml

Markus Bernhardt

unread,
Mar 3, 2014, 5:33:07 PM3/3/14
to arkady.y...@gmail.com, robotframe...@googlegroups.com
Hi,

the easiest solution would be to also execute the tests by maven.

Could you please generate a sample project as described here:

Then move on from there.

Cheers,
Markus


--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/groups/opt_out.
<pom.xml>

Kevin O.

unread,
Mar 3, 2014, 11:02:19 PM3/3/14
to robotframe...@googlegroups.com
yankovskya,
If you look in your PYTHONPATH in the output, you see that the site-packages for your Python installation comes before the __classpath__ entry.
In your scenario, there is a Python module called Selenium2Library and a class Selenium2Library in the default package.
Since the Python module is found first, it is used and fails because the Python version of Selenium does not work in Jython.
Markus suggestion to use Maven will fix this because there will not be extra things on the path - it is well-controlled with Maven.
If that route is not acceptable, you can remedy this by making sure the Java class is found before the Python module.
One way to do this is to pass extra parameters to jybot. To your runner parameters, try adding:
--pythonpath C:\Users\yankovskya\Documents\Automation\Frameworks\RobotFramework\RF-Selenium2library-java\target\robotframework-selenium2library-java-1.4.0.5-SNAPSHOT-jar-with-dependencies.jar
In RIDE, you can paste this into the arguments text box.

yankovskya

unread,
Mar 4, 2014, 12:44:27 PM3/4/14
to robotframe...@googlegroups.com
Thank you Kevin,

Even though your solution didn't work, but it gave me an idea to make a trick.
I've tried supplying jar-with-dependencies.jar as runner parameter to jybot and indeed it was found in PYTHONPATH first, but by some reason RF still referenced Selenium2Library from Python site-packages. So the solution was either remove or rename that Selenium2Library in Python. 

董浩

unread,
Oct 27, 2015, 4:13:11 AM10/27/15
to robotframework-users
The same problem keep me for a long time. Have you solved it now?Could you please tell me how to do.

在 2014年3月5日星期三 UTC+8上午1:44:27,arkadyy写道:

董浩

unread,
Oct 27, 2015, 4:13:11 AM10/27/15
to robotframework-users
And I run my testsuite by custom script, like this(selenium2_script.bat):

del ..\output\*.xml /Q
del ..\output\*.html /Q

set CLASSPATH="%CLASSPATH%;lib\robotframework-selenium2library-java-1.4.0.8-SNAPSHOT-jar-with-dependencies.jar"
echo %CLASSPATH%

jybot --outputdir ..\output ..\suite\Selenium2LibraryTest.txt

But there are still errors:
[ ERROR ] Error in file 'D:\eclipse_workspace\MyTestLibrary\src\robot\suite\Selenium2LibraryTest.txt': Initializing test library 'Selenium2Library' with no arguments failed: maximum recursion depth exceeded (Java StackOverflowError)
Traceback (most recent call last):
  None
test                                                                  | FAIL |
No keyword with name 'Open Browser' found.
------------------------------------------------------------------------------
Selenium2LibraryTest                                                  | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
Output:  D:\eclipse_workspace\MyTestLibrary\src\robot\output\output.xml

[ ERROR ] Reading XML source 'D:\eclipse_workspace\MyTestLibrary\src\robot\output\output.xml' failed: Incompatible XML element 'kw'.

Try --help for usage information.

在 2014年3月5日星期三 UTC+8上午1:44:27,arkadyy写道:
Thank you Kevin,
Reply all
Reply to author
Forward
0 new messages