• Selenium Video Tutorials

Selenium IDE - Code Export



Selenium IDE code generated by recording a test for an application can be exported to other languages like Java, C#, and so on. The generated code can be imported into other IDEs like Eclipse, IntelliJ, and so on and be used for other automation tests.

Steps To Code Export

Step 1 − Follow the Steps 1 to 8 as discussed in Selenium IDE Test Creation.

Step 2 − Save the project in a location.

Selenium IDE Code Export 1

Step 3 − Run the test with the help Run current test.

Step 4 − As the execution completed, the message - <TEST NAME> completed successfully appeared under the Log tab.

Selenium IDE Code Export 2

Step 5 − As test execution successfully completed, we can infer that the test is working fine, and its code can be reused. For this purpose of reuse, we would need to export the code generated for this test.

Click on the three dots appearing beside the test case name in the upper left corner as shown in the below image.

Selenium IDE Code Export 3

Step 6 − Select the option Export from the dropdown visible.

Selenium IDE Code Export 4

Step 7 − Select the language, and click on the Export button.

Selenium IDE Code Export 5

Step 8 − Specify the name, and the location where the Selenium IDE code would be exported. Then click on the Save button.

If the selected language is chosen as Java JUnit, the exported version should have the extension as .java.

Step 7 − Import this file to IntelliJ or Eclipse, and add the required dependencies to support the JUnit test generated from the Selenium IDE. Currently, Selenium IDE code can be exported to the below languages and frameworks −

  • C# Unit
  • Java JUnit
  • JavaScript Mocha
  • Python pytest
  • Ruby RSpec

Process Exported Code and Add Dependencies to Test

Step 1 − The Java JUnit code exported would work with Java version 8 and above, JUnit 4.12, and support the latest version of Selenium available.

Step 2 − In order to reuse the code exported from Selenium IDE, add the Selenium, and JUnit Maven dependencies to the pom.xml file from the links Selenium Java and JUnit.

Please note, we have added the Selenium 4.x version dependencies to make the code compatible. With IntelliJ, the Java version in the system should be 17 or higher. However with Eclipse, Java version 8 or above would be fine.

Conclusion

This concludes our comprehensive take on the tutorial on Selenium IDE Code Export. We’ve started with describing steps to code export. This equips you with in-depth knowledge of the Code Export in Selenium IDE. It is wise to keep practicing what you’ve learned and exploring others relevant to Selenium to deepen your understanding and expand your horizons.

Advertisements