This site requires JavaScript to be enabled
IE BUMPER

Logo

Dear Tricentis qTest users,

If you would like to submit a Tricentis qTest ticket,

please use this support request form.

Tosca Version
IncidentLookup using list
Language
How can we help?

Solution Suggestions

Please enter your question to get suggestions.
  Help
IE BUMPER
Categories
Boolean Operators
OR or vertical bar symbol (|)
Finds a match if either the terms exist in a document (a union using sets).
AND
Finds a match if both terms exist in a document (an intersection of sets).
NOT, minus (-), or exclamation point (!)
Excludes documents that contain the term after NOT (a difference of sets).
Wildcards
Asterisk (*)
The asterisk symbol performs a multi character wildcard search.
Percent sign (%)
The percent sign performs a single character wildcard search.
Phrases
Quotation marks (")
Use quotation marks to search for an exact phrase with multiple terms.
For examples and more information look at our Knowledge Base: Advanced Search On The Support Portal

Reading strings from Excel and testing for equality in TDM Studio

Short summary what this article is about


Situation

Working with Excel always requires the utmost vigilance, as this experience report once again makes clear. Abandonment of an existing Q-upProject was to read test data from an Excel file. In order to further process these test data, it was first necessary to use the values from a line of the Excel file. Q-up-program created array to assign. To identify the correct line from the Excel file, the first cell of that line was checked for its contents. Only the line that contained the "Record 2" string in that first cell should be read out.

The review took place by the following code:

if (arrAktuelleZeile [0] = = "Record 2") then

invalideSchluesselnummer = arrAktuelleZeilen [5];

endif

To understand the code, you need to know that the Excel line in the array arrAktuelleZeile The first value of which was checked for the content at index position 0. Should the text "Record 2" be there, then the value at index position 5, which in this case contained an invalid, because formally incorrect key number of an employee, should be in the variable invalideSchluesselnummer Stored.

In the Excel file, the line for the second record read the following:

Record

              Testfallnummer

              Name

              Surname

              Personalnummer

              Closing number

Record 2

              450013

              Vorname_2

              Nachname_2

              87344207

              B1234

Since "Record 2" was actually shown in the first cell, the above condition for the ifStatement arrAktuelleZeile [0] = = "Record 2," on true Evaluate and value "B1234" from the line of the variable invalideSchluesselnummer Assign.

Contrary to all expectations, however, the condition was met with the result. false Evaluated.

The following attempts to find the bug failed:

 

    The suspicion that similar to the programming language Java instead of "= =" perhaps a function such as equals() to be used for checking for letter inequality of strings was unjustified in this case. The Test Data Language (TDL) by Q-up Actually provides for the operator "= =" for this test (see Cape 8.4 operators, Q-up Handbuch Version 1.4)

 

 

    Also, the suspicion that in the Excel file not a string, but a value with A completely different type of data stood, proved unfounded.

 

The following check for all possible data types of the read value

if (IsOfType(arrAktuelleZeile [0], TYPE_INTEGER)) then

trace(TRACELEVEL_INFO, Street(arrAktuelleZeile [0]) + ": is of type integer");

endif

if (IsOfType(arrAktuelleZeile [0], TYPE_FLOAT)) then

trace(TRACELEVEL_INFO, Street(arrAktuelleZeile [0]) + ": is of type float");

endif

if (IsOfType(arrAktuelleZeile [0], TYPE_BOOLEAN)) then

trace(TRACELEVEL_INFO, Street(arrAktuelleZeile [0]) + ": is of type boolean");

endif

if (IsOfType(arrAktuelleZeile [0], TYPE_STRING)) then

trace(TRACELEVEL_INFO, Street(arrAktuelleZeile [0]) + ": is of type string");

endif

if (IsOfType(arrAktuelleZeile [0], TYPE_TIME)) then

trace(TRACELEVEL_INFO, Street(arrAktuelleZeile [0]) + ": is of type time");

endif

if (IsOfType(arrAktuelleZeile [0], TYPE_ARRAY)) then

trace(TRACELEVEL_INFO, Street(arrAktuelleZeile [0]) + ": is of type array");

endif

if (IsOfType(arrAktuelleZeile [0], TYPE_CULTURE)) then

trace(TRACELEVEL_INFO, Street(arrAktuelleZeile [0]) + ": is of type culture");

endif

 

In the output window, clearly provided:

Record 2: is of type string

 

    That made it clear that both cases were strings chains. This had to be examined again in more detail. Both strings were issued again for comparison in the output window

 

Trace(TRACELEVEL_INFO, Street(arrAktuelleZeile [0]) + ": This is the string from the Excel file");

Trace(TRACELEVEL _ INFO, "Record 2" + ": This is the string from the if-statement ");

The result in the output window was again clear, both strings had to be the same:

"Record 2: This is the string from the Excel file

"Record 2: This is the string from the ifStatement

 

    Only the attempt to assign the contents of the cell from the Excel file through a manual copy & paste to a redefined variable in the current template finally brought the solution. The value from the Excel file now showed its true shape:

 

String wertAusDerExcelDatei = "Record 2

“;

 

The Excel cell contained a return sign that the author had inserted into the Excel file a long time ago for the uniform design of the cell heights:

 

Record

              Testfallnummer

              Name

              Surname

              Personalnummer

              Closing number

Record 2

              450013

              Vorname_2

              Nachname_2

              87344207

              B1234

Conclusion:

So both strings could not be recognized as equal, even though they appeared to the user to be the same. Because Excel did not show the return sign, and Q-up Is set in such a way that it does not display line breaks in the output window so as not to make the output too long and thus too confusing

 

Solution

 

[opt.] Reference

 

IE BUMPER

Tosca is the perfect solution

Optimize - Manage - Automate

Download Trial