How many hours do you spend maintaining your Tosca Commander test cases? Probably more than you would like, right?
Tosca Commander is one of the best test automation tools on the market. But you still need to maintain the test cases you create.
This blog contains a small sample of experiences, tips and tricks that our Automation Genius have collected and refined over the years. These can save you many hours of headaches and maintenance in the future.
The test case is created and it runs perfectly. But as soon as you restart the System Under Test (SUT), nothing works anymore! What happened?
To control an element in a SUT, Tosca Commader requires technical IDs to identify it. However, in some cases the technical IDs have a dynamic element built in, e.g. a number. This element may change from time to time or after a reboot of the SUT or a redeployment.
This makes it difficult to identify the element and you need a way to compensate for this. A very simple way to do this is to integrate wildcards or Regular Expressions (RegEx) into the technical ID.
The following screenshot shows a RegEx example where the caption, i.e. the title of the window, is used as technical ID. The RegEx allows the identification of the window in two languages.
It is after 5 pm and suddenly your Tosca test cases fail! Your SUT probably behaves differently at certain times of the day. This may be due, for example, to the fact that the SUT undergoes a processing change after the end of the working day.
In such a case, it may make sense to create two test cases: one for before 5pm and one for after 5pm.
However, this requires a detailed knowledge of the SUT, accurate documentation, good planning and a working scheduler. Following the Pareto principle, you may come to the conclusion that the effort for these 2 test cases exceeds your already tight budget.
If your testers are experienced enough, they will know these limits. In this case, it might make sense to allow two different results in one test case as correct and completely avoid the additional planning, setting up a scheduler, extended documentation and even creating a second test case.
For this you can again use RegEx, here is an example:
{REGEX["Placed|Completed"]}
Valid values for the status are now "Placed and "Completed".
Verification is the most important part of a test case. This is often done by verifying a value in a text of the application. In some test scenarios, values must be verified in buffers because there are no control elements in which this can be checked directly. So how can buffers be verified?
It sounds a bit counterintuitive, but the easiest way to do this is to use the TBox Set Buffer module. You specify the name of the buffer you want to verify and "Value" contains the value it should correspond to. But you use the ActionMode "Verify" instead of "Input".
In the following example, the "Status" buffer is checked for the value "Payment successful".
After the previous tip, let's take this one step further. String operations are a very important part to process text in the SUT. To get your strings from your SUT, you need to buffer them. Often this involves buffering more text than necessary. For example, from the text "Sum: CHF 350.00" it only needs the "350.00".
The easiest way is to use the dynamic expression {XB}. With this expression you can buffer parts of a fixed record and verify it at the same time. Here, the above example is verified and the sum is extracted to the "Sum" buffer.
The resulting buffers have been given the following values:
Again, a more advanced method of buffering parts of a string is to use Regular Expressions. RegEx looks for patterns rather than a fixed text and is therefore more flexible.
Capturing groups" can also be defined. Tosca has implemented these in such a way that the "Capturing Groups" values found are transferred to Buffer.
Here is an example of a Regular Expression that buffers an address into its constituent parts:
And here are the resulting buffers:
Bonus tip: Infometis Youtube
Michael Weiglein provides a great example with detailed explanation in his YouTube video: https://youtu.be/q9cQTuo_oD4.
If you want to shorten a string to an optional length, you can do this very conveniently using RegEx. Optional, since it may not be known beforehand whether the initial length of the base string is shorter or longer than that of the target string. The length specification {0,15} indicates that the target string is shortened to 15 characters if the base string is longer than 15 characters. If the base string is shorter than 15 characters, then the target string is exactly the same as the base string.
Resulting buffers:
If you have been working mainly with the CALC function of Tosca Commander, the new TBox functions now offer a better alternative to it in most cases. The preceding tips are good examples of how this works without CALC. On the one hand you don't need a pre-installed Excel anymore and on the other hand the execution with TBox Dynamic Expressions becomes a lot more performant.
Since version 14.2 Tosca Commaner now supports "String Operations" with the help of Dynamic Expressions. These can also be used to replace a large part of the CALC functionality.
Here is just a brief overview of the new operations available:
{STRINGTOLOWER[InputText]}:
{STRINGTOUPPER[InputText]}:
{TRIM[InputText][Optionale Parameter]}:
{BASE64[InputText]}:
{STRINGREPLACE[InputText][Pattern][NewValue][Optionaler Parameter1, Optionaler Parameter2]}:
{NUMBEROFOCCURRENCES[InputText][Pattern][Optionaler Parameter]}:
{STRINGLENGTH[InputText]}:
Detailed information including examples can be found on the following Tricentis documentation page
In this blog we have presented you 7 tips including bonus tip on how to elegantly solve automation problems with Tosca. These tips have already saved Automation Geniuses hours of maintenance work and we hope it will be the same for you.
If you want even more tips about Tosca, you might also be interested in the following article:
Top 5 mistakes Tosca beginners do and how to avoid them
In addition, we offer Tosca training courses with certification, where we are happy to share our knowledge and experience with you in greater depth.
Happy Automation!
You would like to use our expertise and implement technological innovations?
Do you have a question or are you looking for more information? Enter your contact information and we will call you back.