NEW! Root Cause - Open Source Project for Puppeteer and Playwright MORE

Using Testim TDK (Test Development Kit)

Testim provides the capability to export tests from the main codeless editor to the filesystem where they can be hosted…

By Barry Solomon,

Testim provides the capability to export tests from the main codeless editor to the filesystem where they can be hosted by the Visual Studio Code IDE (VSCode).

Tests are exported as either TypeScript or JavaScript as a single test file with an associated directory that contains all data needed for Testim’s Smart Locators as well as a mapping file that links the test object names to their associated selector data used by Testim’s AI.

To export a test, open the target test and press the export button

If the Testim agent is not running you will be prompted to start it.

To start the agent, open the run command window (Win-R) and open “cmd.exe” as shown below.

Once the command window is open, make sure you navigate to a known directory before starting the agent, so that you know where your exported test lands, otherwise you will be searching the filesystem for your tests and that is no fun.   

Run the following command in the command shell

You can run the shorter command that does not install/update testim, but this can get out of sync with our deployments, so buyer beware.  Personally, I use the shorter and then update when something does not smell right.

Next choose the language and name of the test you wish to export.

The resulting export will consist of a folder (locators) of the dynamic locators and the associated linking file “locators.cs” used by the testcase for finding objects (in this instance “MyAwesomeTest.js”).

Now, of course, these files sitting in some directory does not help anyone, so we really need to create a VSCode project to host them.  Ideally, this project will become our main test container for all of our individual test cases exported from Testim.

  1. Create a TDK directory on a network share or some local directory that makes sense to you.

For my needs, I created the directory C:\Projects\Testim\TDK

  1. In this directory, create a Testim VSCode project named “testim_main” by running the command

  1. After the project is created, open the project directory using VSCode.

For convenience, pin the “testim_main” directory in the VSCode Taskbar menu for ease of access.

Making things Simple

As we learned, in order to export code from Testim, the Testim agent must be running.  Exported tests are created in the directory that the agent is running in.  Therefore, we will want to run the agent in our TDK Test directory, so we do not need to track them down after export.

When I first started using TDK, I would open a command prompt, navigate to C:\Projects\Testim\TDK\ExportSandbox and then start the agent “testim –agent” or “testim connect”.

I then thought I was clever and made a batch file on my desktop that set the target directory and started the agent.

BUT… Being the lazy person that I am, that was even too much for me, so I would simply start the agent from the Terminal provided in my VSCode project that happens to be situated in the directory I want tests to export to.  Cool.

  

In Summary, by having a top-level project with all your tests, you do not need to deal with the filesystem and all your tests can share smart locators.  When you export to a directory/project, the locators directory and mapping file are automatically updated with the new objects.  

Now when we re-export our test, it will be added to our super TDK Test and any subsequent tests will likewise be incorporated into our super test.

Testim's latest articles, right in your inbox.

From our latest feature releases, to the way it impacts the businesses of our clients, follow the evolution of our product

Blog Subscribe