logo logo

Export Recorded iOS, Android and Web Tests to Java with TestProject

main post image

The term “record and playback” gets a lot of bad rep in the test automation community and some don’t find it to be as beneficial as coded tests. However, I find such tools to be of great advantage, especially if used in a smart way while utilizing best practice to enhance your automated test cases. It should not be one method or the other, but rather a “mix and match” of both recorded features and coded ones that can together help us all achieve our own unique test automation goals

Recently, Louise Gibbs wrote two interesting posts sharing the benefits of recorded tests and how to adapt recorded test cases to improve your test automation. One of the biggest benefits is the ability to automatically generate code from recorded test, instead of spending a lot of time and effort on manually developing the code yourself. This is where TestProject‘s new feature comes in that will definitely speed up your time to market and overall productivity!

With TestProject‘s test automation platform you now have the ability to automatically generate Java code from all of your recorded iOS, Android and Web tests. Once generated, you can open your tests in your favorite IDE such as IntelliJ IDEA or Eclipse, make any code alterations you want to, extend your tests even further, and upload them back to TestProject to execute them and review their report dashboards, share them with your teammates, and eventually gain more robust automated test cases

Additionally, if anyone from your team in not an expert developer, they can leverage this cool new feature to start learning code:

“Recording features are an excellent learning tool. The code is automatically generated which enables the developer to examine and learn from it. From this, the developer can gain confidence in their programming skills. These skills can be used to update and maintain existing automated tests, and develop new tests” – Louise Gibbs – “Benefits of record and Playback Features in test Automation”.

Let’s Start Exporting Your Recorded Tests to Code

All you need is to follow 3 simple steps:

  1. Sign up here to TestProject. Don’t worry, it’s free!  😉 
  2. Login to TestProject and install the TestProject Agent (it incorporates all of the tools and drivers you need for your test automation, in one small desktop local component). Watch this short video to see how easily you can setup your Agent.
  3. That’s it, start testing!

Now that you have your TestProject Agent all setup and ready to go – you can start creating recorded and coded tests for Web, Android and iOS apps.

Let’s for example create a web recorded test for TestProject’s demo website (With TestProject you can create Web, Android and iOS tests) and create an automated login test. Here are the test steps that were recorded using TestProject’s Smart Test Recorder:

recorded steps

In order to export recorded tests to code, all you need to do is click the three dots at the right corner of your test and choose to “Generate Code” for the test you want to export: 

generate code

Then, you will receive an email with a link to the test code, that will include the following:

1. The test code of your recorded test. Here is the code that was generated from our example recorded test (that was described above): 

2. The runner file (that helps you to debug your test) which includes the default agent configuration: runner

3. Gradle project files, allowing you to open your test’s code in your favorite IDE and start working on your code immediately!

4. And lastly, in case your test uses any external actions from the addons library, TestProject’s code generator will also download and generate the proxy interfaces for them as well, so that your code project contains the test with all the dependencies ready for coding and debugging.

Here is how the folder structure will look like:

folder structure

 

Now, you can open your generated test code in your favorite IDE and make any alterations you’d like (by using pure selenium webdriver or extended TestProject webdriver methods), continue the test flow and get the ability to create advanced scenarios. Here, for example, we’ve added a few simple lines of code that also perform the logout from the TestProject demo website (This is just an example, but of course you can further extend your code to fit your exact requirements): 

new code

 

Once you’ve completed your alterations, you can compile the code back to a JAR file and upload to TestProject by following these steps:

1. Click on the “NEW TEST” button, choose the “Code” test type and select your project:

 

2. Upload your JAR file:

 

3. Create the test package:

 

4. Now you are all set to start testing:

 

5. You can see here the test package you have just created. You can click to expand it and view its included tests and execute them by clicking the “play” button:

What’s next? Soon you will also be able to export your code for C# (.NET core) as well!

Go ahead and give this new feature a shot! Let us know your feedback in the comments below and feel free to reach out if you have any questions  😀 

Shai Glatshtein

About the author

Shai Glatshtein

Join TestProject Community

Get full access to the world's first cloud-based, open source friendly testing community. Enjoy TestProject's end-to-end test automation Platform, Forum, Blog and Docs - All for FREE.

Join Us Now  

Leave a Reply

Join TestProject Newsletter

Join a 20K community of readers! Always stay up-to-date with all the latest test automation trends, best practice and tips shared by leading software testing community experts across the globe!

FacebookLinkedInTwitterEmail