TestProject Forum
Powered by leading experts in the test automation community

Automated Elements Creation/Deletion

Is there a way to generate elements by code and to delete them?



Can you please elaborate a bit more about what you mean by generating elements by code and deleting them? What are you trying to implement?

Hi David,

we have the idea, that before a test runs we have a kind of seed command,
that generates all elements and parameters for this tests. Maybe with
initializing with values. So we can concentrate on th teststeps themselves.

Another thing we want is a command to remove all elements in a project,
except these that are whitelisted.


If you would like to do something like that in the recorder, you can use the random data generator addons and place them at the start of your test and have all your parameters receive their values from them at the start of the execution.

Alternatively, creating something more specific should be implemented in your code, you can create a method that creates and sets all your random values using a seed and then use it in the execute method you have implemented from the interface.

And regarding deleting parameters from your project, you can do that using our API:


Use this API call multiple times on each element you would like to remove, refer to the API documentation for more details.

The idea with the API calls sounds good to me, I will try this.

The generation of new elements with the help of a self defined add on seems to be trickier I assume? Is it possible at all?


Using your addon to create an action that will generate the random values that you need and then use them during your recorded test is possible.
You will just need to set the output parameter of this action to be one of the parameters you intend to use during your execution, which will need to be done inside the recorder.

Hmm, I think there is a misconception, sorry for that.
It is not so interesting to generate random values, especially
during recording. What we try to find out is, if we can create
Elementdefinitions via an add on. And to remove these definitions

Kind of action step “createElement FunnyName Type Value” or
“deleteElement FunnyName”


Regarding this, you can use project parameters as element locator values for your tests.

Create these parameters in your project, then create elements in your tests that use these parameters as locator values to search for elements on the page.

You can create/delete/edit these parameters dynamically using the API as suggested previously, there are API calls exactly for those actions:


We are planning on adding API calls that will let you do the same to specific test elements in the future.

This sounds very interesting to me. Then I create the Parameter via API on the fly, use it in the element and thats it.

Thank you.