How to Export Java Code from Selenium IDE

How To

Selenium LogoIf you’re reading this, you’re probably familiar with Selenium IDE, a Firefox extension that lets you record actions and turn them into automated test scripts.

Maybe you’ve created your first recording, and now you’re wondering how you can export the raw Java code. Read on for step-by-step instructions!

Getting Java Code from Selenium IDE:

  1. Open Selenium IDE, and select the recording you want to use in the “Test Cases” list (see the left nav)
  2. In the top menu, click “Options” and in the resulting drop-down, select “Options…”
  3. Make sure the option for “Enable experimental features” is checked, and click “OK”
  4. Click on “Options” again in the top menu, and select “Format”
  5. Choose the Java test case format you want the code in — for example, “Java / TestNG / WebDriver”
  6. Copy the code that shows up (in the “Source” tab), and use it however you’d like!

For example, you can create an Eclipse TestNG file and paste the code in there. Just delete any irrelevant placeholder code in your new file, and remove the package name from the top of your Selenium IDE code, as you’ll already have a package name in your Eclipse file.

Do you use a different language than Java in your automated tests? No problem! For step number five above, you can choose Python, Ruby, or C# instead.

Leave a Reply

Your email address will not be published. Required fields are marked *