Skip to content

zagasilva/robotframework-selenium2library-java

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java port of the Selenium 2 (WebDriver) Python library for Robot Framework

Introduction

This Java port of the existing Selenium2Library was created to enable the usage of a Selenium 2 library with Jython.

  • Python Selenium2Library needs Python 2.6 upwards
  • The latests stable release of Jython is 2.5.3
  • Jython 2.7a2 is a alpha version and missing essential features
  • There seems to be no further development of a stable Jython 2.7

Usage

This library is a direct replacement to the Python Selenium2Library. There are almost no changes necesssary to the existing code. You can execute the same testcases and keywords with Python and Jython.

If you are using the robotframework-maven-plugin you can use this library by adding the following dependency to your pom.xml:

<dependency>
    <groupId>com.github.markusbernhardt</groupId>
    <artifactId>robotframework-selenium2library-java</artifactId>
    <version>1.1.0.4</version>
    <scope>test</scope>
</dependency>

Differences

  • Robotframework does not support providing arguments to Java libraries

    With Python it is possible to provide arguments to libraries

      *** Settings ***
      Library    Selenium2Library    15    30    run_on_failure=Log Source
    

    This is not possible with a Java Library. But it can be done in a way that works with Java and Python

      *** Settings ***
      Library    Selenium2Library
      
      *** Keywords ***
      Open
          Open Browser    <url>    <browser>
          Set Selenium Timeout    15
          Set Selenium Implicit Wait    30
          Register Keyword To Run On Failure    Log Source
    
  • Robotframework does not support named arguments with Java libraries

    It is not possible to use named arguments. See User Guide 2.2.2

  • Selenium Speed not implemented

    Setting the Selenium Speed is deprecated several years and not implemented in WebDriver. The Python Selenium2Library tries to emulate the old behavior. I have not implemented this emulation for the following reasons.

    • As far as I understand the emulation is broken and only works with RemoteWebDriver
    • I do not know how to implement that in a correct way with Java
    • There is a reason, why this is not implemented in WebDriver. It's a bad idea.

Enhancements

Proxy Handling
We added proper proxy handling for RemoteWebDriver instances. This is needed, if you want to connect to an external Selenium grid through a local HTTP proxy. Our implementation handles BASIC, DIGEST and NTLM based authentication schemes correctly. We added the following keyword.
KeywordArguments
Set Remote Web Driver Proxyhost,port,user=NONE,password=NONE,domain=NONE,workstation=NONE
Some additional info:
  • If you set a proxy, it will be used for all subsequent calls of Open Browser
  • You can remove the proxy by calling: Set Remote Web Driver Proxy ${EMPTY} ${EMPTY}
  • If you provide no username, we are looking for a username at the Java property http.proxyUser and the environment variables HTTP_PROXY and http_proxy. If we find a username, it is only used, if the host and port also match.
  • If you provide no password, we are looking for a password at the Java property http.proxyUser and the environment variables HTTP_PROXY and http_proxy. If we find a password, it is only used, if the host, port and username also match.
  • If you provide a domain, we use NTLM based authentication
  • If you provide no workstation and we use NTLM based authentication, we use the hostname as workstation name
Waiting
Our application is heavily using AJAX. So much more waiting keywords are needed. The list of new keywords:
KeywordArguments
Element Should Be Clickablelocator,message=NONE
Element Should Not Be Clickablelocator,message=NONE
Element Should Be Selectedlocator,message=NONE
Element Should Not Be Selectedlocator,message=NONE
Element Should Not Containlocator,expected,message=NONE
Element Should Text Should Not Belocator,expected,message=NONE
Wait Until Element Is Clickablelocator,timeout=NONE,message=NONE
Wait Until Element Is Successfully Clickedlocator,timeout=NONE,message=NONE
Wait Until Element Is Not Clickablelocator,timeout=NONE,message=NONE
Wait Until Element Is Selectedlocator,timeout=NONE,message=NONE
Wait Until Element Is Not Selectedlocator,timeout=NONE,message=NONE
Wait Until Element Is Visiblelocator,timeout=NONE,message=NONE
Wait Until Element Is Not Visiblelocator,timeout=NONE,message=NONE
Wait Until Page Not Containscondition,timeout=NONE,message=NONE
Wait Until Page Not Contains Elementlocator,timeout=NONE,message=NONE
Wait Until Title Istitle,timeout=NONE,message=NONE
Wait Until Title Is Nottitle,timeout=NONE,message=NONE
Wait Until Title Containstitle,timeout=NONE,message=NONE
Wait Until Title Not Containstitle,timeout=NONE,message=NONE
XPatch Count
We extended the following keywords to be called with a xpath statement that optionally can start with "xpath=".
KeywordArguments
Get Matching Xpath Countxpath
Xpath Should Match X Timesxpath, expected_xpath_count, message=NONE, loglevel=INFO

Demo

This is a maven project. If you have firefox installed, you can execute the unit tests with:

mvn integration-test

About

Java port of the Selenium 2 (WebDriver) Python library for Robot Framework

Resources

License

Stars

Watchers

Forks

Packages

No packages published