Binary Search Function


After installation of the Module for Binary Formats, a new function appears in the list of WAPT internal functions - Binary Search.

This function can extract binary values from server responses by the left and right boundaries and/or by the offset and length. The extracted value can be assigned to a WAPT Pro variable in hexadecimal form or as a string of text.

Syntax: VarName=$BinSearch(LeftBoundary,RightBoundary,Index)

The index specifies the number of occurrence that should be used in case such value is found in more than one place. Index equal to 0 is used to specify random occurrence.

Left/Right boundary hexadecimal notation: Here you can specify the left and right boundaries of a binary value you want to search for.

Search from offset/Search to offset: Check these options if you want to specify an interval of search inside server response. 'Search from offset' value is the beginning of this interval; 'Search to offset' is its length. The initial reference point for both offsets is the beginning of server response.

Offset values narrow down the area of search. They are useful if you know the position of searched binary value inside the server response.

Extract value as: Select the output format of the binary value in the drop-down list. You can extract the binary value in hexadecimal form or as a string of text.

Below you can see several examples of usage of Binary Search function.

Example 1


Suppose that the body of server response has the following binary view:



To extract the Id value from this binary code, we define the following variable:

In this example the value is extracted as a string of text. You can click the "Test" button to see the result:



Created variable can be used in subsequent requests. Here we use the ID variable to define the URL parameter that will be inserted in the URL path of GET-request:



During the test run the value surrounded by the specified boundaries will be extracted from the binary code of server response and assigned to the ID variable. The value of this variable will be substituted directly in the URL path of GET-request instead of the initially recorded value.

Example 2


The Module for Binary Formats allows editing the binary data inside requests and using variables in the binary code. If you insert variables inside the binary data of requests, you should use values in the hexadecimal form. A simple text string cannot be used in this case.



In this example we take the ID variable from the previous example, extract the value in the hexadecimal form and insert it in the body of POST-request. To insert a variable in the binary code, enter the $ sign and you will see a prompt with the list of available variables. Select a desired variable in the list.



During the test run the value of ID variable will be substituted in the body of current POST-request instead of the initially recorded value.

Next page