Dashboard > Selenium IDE > ... > Contributed Extensions and Formats > Java driven mode
Selenium IDE Log In View a printable version of the current page.
Java driven mode
Added by Ignaz Forster, last edited by Ignaz Forster on Jun 15, 2006  (view change)
Labels: 
(None)

Generates code for the Java driven mode or Selenium RC with Java.

Note: Since Selenium 0.8.0 a Java converter is already included, so I will stop further development if nobody complains. This extension may be still usefull if you want to convert your Java tests back into HTML format.

When creating a new test a new JUnit test will be generated. You can also use this script to edit existing Java tests or convert your tests between Selenium IDE and Java driven mode. The script supports both the old Selenese Java driver distributed with Selenium up to 0.6.x and Selenium RC (Selenium Core from 0.7.0).

When you load a file the Java code may contain several JUnit test functions inside. The parser will try to detect a header and a footer if specified in the options to avoid displaying unnecessary information in Selenium IDE table view. Everything not identified as a Selenium command or a comment (i.e. normal Java functions or Javadoc comments) will be displayed as a comment with the prefix java: in the table view.

Please note that conversion is not lossless. For example all verify Selenium commands will be converted to assert commands for the JUnit test - unfortunatly they won't be restored when you load them in Selenium IDE again. Additionally the source code will be massively refactored.

Download: java.js

Installation instructions:

For this plugin you need at least version 0.7.0 of Selenium IDE.

  1. Download the file "java.js"
  2. Open Selenium IDE and select "Options" -> "Options..." -> "Formats" -> "Add"
  3. Enter a name for the Format (for example "Java") and copy the contents of the above file into the large textfield
  4. Select "OK" -> "OK"

Now you can use the menu "Options" -> "Format" to select the format or go to "Options" -> "Options..." -> "Formats" -> "Name" to adjust preferences.

Known Issues:

  • Java: If a selenium or assert command is spread over several lines and contains a String with a semicolon (";") the command may not be detected.
  • The following Selenium commands don't have any equivalent in Selenium RC 0.7.2 and won't be converted automatically:
    actions: addSelection, removeSelection, waitForPopUp, refresh, setTimeout
    accessors: AlertPresent, PromptPresent, ConfirmationPresent, Location, SelectedOptions, HtmlSource
    waitFor* and store* accessors are generally not implemented with the exception of waitForCondition and waitForPageToLoad. If you need one of the waitFor* commands, you may try to get the latest version of Selenium RC from SVN.
  • Detecting the footer sometimes fails. If you have problems (for example if the script hangs), please turn header / footer detection off in the options.

Updates:
19.05.2006: Support for Selenium RC, automatic verify* to assert* command conversion
02.03.2006: Added recognition for Javadoc comments; comments delimited by /* */ will be handled as java: comments now, not as common Selenium comments; small bug fixes

Hi Forster,

  I think you have develoed really a nice thing. Java developers are familiar with unit based test cases and your efforts have eliminated their learning curve in ruby.

  Selenium's record/play capability and junit test cases make life easier.

Posted by vijay at Apr 20, 2006 05:15

Hi,

how do you handle *AndWait commands?

In Html I have

clickAndWait <button>

I translate it to java

selenium.click(<button>);
selenium.waitForPageToLoad("5000");

since in Java, the AndWait commands seem to be missing.
But when executing within the IDE, the waitForPageToLoad is unknown.

 JPT

Posted by JPT at May 05, 2006 07:05

Hi JPT,

 the current script doesn't work with Selenium RC. I'm currently working on a new version with support for Selenium RC which should be out before the end of next week (19.5.).

Greetings,
Ignaz 

Site running on a free Atlassian Confluence Community License granted to OpenQA. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.6 Build:#812 Aug 06, 2007) - Bug/feature request - Contact Administrators