Want to save a lot of time and effort on manually developing code yourself? Interested in learning how to code? Believe it or not – Record and playback might be the answer for you! But not just any recording tool… With TestProject‘s test automation platform you now have the ability to automatically generate C# Selenium/Appium API-based code, including embedded comments from all of your recorded iOS, Android and Web tests, in order to speed up your time to market and overall productivity.
Once generated, you can open your tests in your favorite IDE such as Visual Studio or VS code, 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.
More of a Java kind of Guy/Girl? We’ve got you covered! Read this article to learn how you can also automatically generate Java code from all of your recorded web and mobile tests.
Let’s Start Exporting Your Recorded Tests to Code
All you need is to follow 3 simple steps:
- Sign up here to TestProject. Don’t worry, it’s free! 😉
- 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.
- 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 use the “My First Test” that we’ve automatically created for you in your “My First Project” once you signed up for a new TestProject account. It’s a web recorded test for TestProject’s demo website that performs some basic actions and validations (With TestProject you can create Web, Android and iOS tests). Here are some of the test steps that were recorded using TestProject’s Smart Test Recorder:
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:
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:
3. A .csproj file, 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:
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 clears the fields we filled out (This is just an example, but of course you can further extend your code to fit your exact requirements):
Once you’ve completed your alterations, you can compile the code back to a DLL 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 DLL file:
3. Create the test package:
4. Now you are all set to start testing your newly uploaded coded test! 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: