30

Is there any application or simple way to convert all the commands recorded by Selenium IDE to Java (Selenium WebDriver)? It would be a lot more easier and would save a lot of time.

Any suggestions will be appreciated. Thanks!

1
  • Do you want to convert whole code to Java at a time? or, Do you like to convert individual command one by one? Oct 30, 2017 at 12:07

5 Answers 5

36

In my Selenium IDE version 2.4.0 it is easy as pie:

  1. Record testcase in Selenium IDE
  2. Click File - Export Test Case As - Java / JUnit4 / WebDriver
  3. Save File as .java

And here you go! Your testcase is converted to WebDriver ;)

1
13

Update: Starting from SeleniumIDE 3.x unfortunately both functions mentioned in previous answers "Export" and "Options->Format" were removed (reason is the porting to the new WebExtensions format of Firefox and Chrome).

But a current alternative is Katalon Recorder which is available for Chrome and Firefox.

Katalon Recorder has an "Export" button and can export 3 Selenium formats, with TestNG, with JUnit and even with Thoughtworks WebDriverBackedSelenium and JUnit.

Just press "Export", choose your format, than "Copy to Clipboard" or "Save as file...".

1
  • Nevertheless, since 2020 at least @imaginabit's answer works by clicking on the test's little side menu (three vertical dots) and choosing "Export".
    – MiB
    Dec 5, 2021 at 4:55
7

In my Selenium IDE version 2.4.0

Record a new test case with the help of Selenium IDE

 1) Click on File a primary nav bar
 2) check drop down is displayed
 3) select on Export test case as 
 4) Check you can convert selenium test case in any language EG: Java / JUnit4 / WebDriver

Save File as .java
Your testcase is converted to WebDriver

check image enter image description here

5
  • In Selenium IDE 2.9.1 Java / TestNG / WebDriver has been implemented Aug 1, 2017 at 10:25
  • Chrome version doesn't have it.
    – devwebcl
    Jan 17, 2018 at 13:00
  • 2
    In the latest version of the IDE I don't see any of the menu options? Am I loosing my mind?
    – Daryl
    Apr 24, 2018 at 15:05
  • @Daryl Don't see it either. Was able to successfully run previous version if IDE on FF 54. Apr 25, 2018 at 9:28
  • you can see it by right click on the test case selenium.dev/selenium-ide/img/docs/code-export/right-click.png
    – Sally
    Dec 27, 2019 at 6:22
3

There are 2 ways to convert a recorded tests(HTML format) into Java code in Selenium IDE:

1st way: To see the Java code directly in Selenium IDE

  1. Go to Options -> Options...
  2. At "Selenium IDE Options" window: Check the check box for "Enable experimental features" and click OK button
  3. Options -> Format -> Java / JUnit4 / WebDriver
  4. Click OK button from "JavaScript Application" pop up -> You will see the desired Java source code for your recorded tests

2nd way: By exporting recorded test case(HTML format) into java file:

  1. Record your tests in HTML format by using Selenium IDE
  2. File -> Export Test Case As -> Java / JUnit4/ WebDriver
  3. Save the file (it would be saved as .java)
  4. Open the java file you saved in any text editor or IDE such as, Notepad++, Notepad, Wordpad, Eclipse, IntelliJ IDEA etc. (You can see the expected Java Selenium source code)

There is another way to convert Selenium IDE command individually to any language. The following steps for java:

  1. Open Firefox -> Open Selenium IDE
  2. Record some steps of your test
  3. In Selenium IDE: Go to Options | Clipboard Format and select Java / TestNG / WebDriver
  4. Right click any command in Selenium IDE you recorded -> Click Copy
  5. Paste in any editor (such as NotePad, Wordpad etc. OR any IDE you are using such as eclipse, IntelliJ IDEA)
  6. The command will be pasted as Java format

Note: In similar way you can convert individual Selenium IDE command to C#, Python and many more you want.

2
  • In Selenium IDE 2.9.1 Java / TestNG / WebDriver has been implemented. Aug 2, 2017 at 12:39
  • 1
    Selenium IDE 3: Export/conversion option is absent Aug 7, 2019 at 12:08
3

Im using selenium ide firefox extension and find this looking for how to export tests to javascript

I found you can export to C# NUnit, C# xUnit, Java JUnit, JavaScript Mocha, Python ,pytest, Ruby RSpec just right click on the test and a menu with export options appears

some times you can't find the easy way

1
  • Thanks, this works at least in Firefox 95.0. Likely also in every version since your post. What was the current Selenium IDE then, I wonder, and when did this export functionality return, if ever absent.
    – MiB
    Dec 5, 2021 at 4:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.