How to extend Selenium2Library by creating new RobotFramework keywords using Selenium WebDriver in Java

415 views
Skip to first unread message

rubber...@gmail.com

unread,
Aug 26, 2017, 6:30:51 PM8/26/17
to robotframework-users
I'm trying to extend the Selenium2Library python library (1.8.0) by implementing new Robot Framework keywords using Selenium WebDriver in Java.

In order to do that, I need to be able to retrieve the WebDriver instance used by the Selenium2Library python library in my Java keyword.

Please note that I don't want to use the Java port of the Selenium 2 (WebDriver) Python library created by Markus Benhardt since it's based on an older version of Selenium2Library so it's clearly outdated.

I've heard that with Jython 2.7, we can now use the Python version of Selenium2Library on Java... but my question is... how??

My setup is using :

 - Robot Framework Maven Plugin 1.4.7
 - Robot Framework 3.0.2 (as a maven plugin dependency)
 - Selenium Server 2.53.1 (as a maven plugin dependency)
 - Selenium2Library python library (1.8.0)
 - Robot Framework Javalib Core 1.2.1

Here's an extract of my pom.xml

    <plugin>
       
<groupId>org.robotframework</groupId>
       
<artifactId>robotframework-maven-plugin</artifactId>
       
<version>1.4.7</version>
       
<configuration>
           
<extraPathDirectories>
               
<extraPathDirectory>/usr/local/lib/python2.7/site-packages</extraPathDirectory>
           
</extraPathDirectories>
       
</configuration>
       
<executions>
           
<execution>
               
<goals>
                   
<goal>run</goal>
               
</goals>
           
</execution>
       
</executions>
       
<dependencies>
           
           
<!-- Robot Framework - High level test automation framework -->
           
<dependency>
               
<groupId>org.robotframework</groupId>
               
<artifactId>robotframework</artifactId>
               
<version>3.0.2</version>
           
</dependency>
           
           
<!-- Selenium Server -->
           
<dependency>
               
<groupId>org.seleniumhq.selenium</groupId>
               
<artifactId>selenium-server</artifactId>
               
<version>2.53.1</version>
           
</dependency>
       
</dependencies>
   
</plugin>

Does anyone have done something like that?

Tatu Aalto

unread,
Aug 29, 2017, 12:41:39 PM8/29/17
to rubber...@gmail.com, robotframework-users
Ugh

It's not possible to extend Python Selenium with Java Selenium. If you want to extend Selenium2Library (Python), then you must use Python. Jython enables to run Python with Java platform.

-Tatu
Send from my mobile


--
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-users+unsubscrib...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Hélio Guilherme

unread,
Aug 29, 2017, 3:10:15 PM8/29/17
to robotframework-users
Have you tried to install with pip?
(after first installing "ensurepip")
jython -m pip install robotframework-selenium2library

Note the new naming of the library is robotframework-selenium2library.

My Favorite Open Source Projects
awsome-lists gretl meld robotframework wxPython
(sponsored/patrocinado) Recomendo servidores e alojamento Web em:
http://www.proalojamento.com/clientes/aff.php?aff=258

To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.

Pekka Klärck

unread,
Aug 29, 2017, 3:37:17 PM8/29/17
to Tatu Aalto, rubber...@gmail.com, robotframework-users
It might actually be possible to use the same browser session from
different programming languages by somehow reusing the original
Selenium session id, but I doubt that's worth the effort. Much better
way to extend Selenium(2)Library is using Python and then using Jython
if you want to run it on JVM. I would expect Selenium(2)Library to
work pretty well with Jython these days, but AFAIK nobody has tested
it extensively. I'm sure SeleniumLibrary could be automatically tested
on Jython, but that would need someone interested about it to set it
up.

Cheers,
.peke
> email to robotframework-u...@googlegroups.com.
> To post to this group, send email to robotframe...@googlegroups.com.
> --
> 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.
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org
Reply all
Reply to author
Forward
0 new messages