Avoiding scripting pitfalls


Review the information on this topic to know some of the pitfalls that you might encounter when scripting, and the possible workarounds.

  • If you change the application version, the workflow might change, and you might have to rescript entirely.
    Some parsing might not work because workflow changed the order in which data is returned. For example, if the previous workflow parsed the entry ID followed by the name, but the new workflow returns the entry ID followed by the job title and then by name, your parsing function will not get the name. Generally, the error appears in a subsequent request because the value is used there.
    To debug, use TryScript to run the script once, and then look at the output in Silk TrueLog Explorer. Check the response of every HTTP call for errors. Sometimes the error says a required field is missing if the value is null. Other times, no errors occur even though the wrong value is provided. These problems are hard to track; to avoid them, verify that the response output matches that of your previous scripts.
  • Sometimes SilkPerformer breaks up a long string because it does not fit the maximum line length. The break can occur at any point in the string. When you search for a word, the word will be missed if a break occurs in it. 
    For example, in the following code sample, the string highlighted in bold is broken in two places. The first break occurs after IM00C04FA081BAUcxmQ. Thus, if you search for IM00C04FA081BAUcxmQg[8XkEQmwAA, you will not find it. To find such breaks before performing search-and-replace operations, scan the right edge of the web forms. If you find a break, put the entire string on one line.
    To configure a longer maximum line length, see Preventing-SilkPerformer-from-recording-the-wait-times.

    ARSYS BACKCHANNEL 018:
    "param":= "<?xml version='1.0'?>\r\n"
    "<SegueRemedyXml operation=\"GetEntryList\">\r\n"
    " <string name=\"current_server\">"+gsARServer+"</string>\r\n"
    " <string name=\"current_schema\">RQC:SummaryDefinition</string>\r\n"
    " <string name=\"server\">"+gsARServer+"</string>\r\n"
    " <string name=\"schema\">SHARE:Application_Properties</string>\r\n"
    " <string name=\"app_name\"></string>\r\n"
    " <string name=\"qualification\">*2\\4\\1\\1\\400081600\\2\\4\\30\\IM00C04FA081BAUcxmQ"
     "\[8XkEQmwAA\\4\\1\\1\\400081600\\2\\4\\30\\ID00"
     "C04F651D063b42125a045484fd\\*</string>\r\n"
    " <Array name=\"qual_field_ids\"></Array>\r\n"
    " <Array name=\"qual_field_values\"></Array>\r\n"
    " <Array name=\"qual_field_types\"></Array>\r\n"
    " <int name=\"no_match_opt\">2</int>\r\n"
    " <int name=\"multi_match_opt\">3</int>\r\n"
    " <Array name=\"fields\">\r\n"
    " <long>400081600</long>\r\n"
    " </Array>\r\n"
    "</SegueRemedyXml>";
  • If you use the SilkPerformer MeasureStart and MeasureStop functions to measure a set of HTTP requests, do not put think times between the MeasureStart and MeasureStop functions; otherwise, they are counted in the response time.
    However, if you use MeasurePause and MeasureResume, you can put think times between the MeasureStart and MeasureStop functions.
  • You might want to set a random seed for the generation of random values. This ensures that all users have a unique random seed and decreases their chance of getting the same random values. Put RndSeed(GetUserId()); in your fInitialize() function.
  • Put login and logout actions in the same transaction if they are not in their respective begin and end transactions. In the dcluser section, specify the transaction order and frequency. The keywords begin and end can be used in only one transaction, and those transactions are executed only once during the simulation. If you put login in the begin transaction, virtual users log in only once during the entire simulation. Likewise, if you put logout in the end transaction, users log out only once during the simulation.
  • Some SilkPerformer functions have a parameter for wait times that is inserted during recording. Make sure these are set to 0 seconds; otherwise, SilkPerformer simulates executing the function for the number of seconds you specify. For example, the bold value (0.00) in the following function is a wait time. It is optional and can be removed or set to 0.
    WebUrl("http://standardhost/arsys/plugins/SRMSServiceRequestBrowser/resources/images/favorites_sub_16.gif", 0.00);
  • SilkPerformer does not check for AR System errors unless you script such checks. Usually, you should put errors checks only in main request calls such as create, search, and modify. Insert a WebParseDataBound function before your HTTP request, then check the response for specific AR Systemerrors.
    Verifying all possible AR Systemerrors is inefficient, so choose the most critical errors.
    For example, the following function checks for specified errors and, when it finds one, either stops the current user or logs the error:

    function verifyErrors(pInStr : String(900000)) : boolean
    var
    error : boolean;
    begin
    error := true;
    if StrSearch(pInStr,"Incorrect login parameters.",STR SEARCH FIRST) > 0 then
    Writeln(gsUsername +" Login Error: ARERR 9295: Incorrect login parameters.");
    elseif StrSearch(pInStr,"ARERR [9201] Session is invalid or has timed out.",STR SEARCH FIRST) > 0 then
    Writeln(gsUsername +" Login: Session is invalid or has timed out");
    elseif StrSearch(pInStr,"Session is invalid or has timed out",STR SEARCH FIRST) > 0 then
    Writeln(gsUsername +" Session is invalid or has timed out");
    elseif StrSearch(pInStr,"User is currently connected from another machine",STR SEARCH FIRST) > 0 then
    <ok?>
    Writeln(gsUsername +"User is currently connected from another machine");
    elseif StrSearch(pInStr, "ARERR [9386]", STR SEARCH FIRST) > 0 then
    Writeln(gsUsername  +"ARERR  [9386] Security Exception\!\!. Possible insecured call is issued.
    Please try opening the report again.",SEVERITY ERROR);
    elseif StrSearch(pInStr, "The AR System Plug-In server is not responding.",STR SEARCH FIRST) > 0 then
    print("ARERR [8939] The AR System Plug-In server is not responding.",
    OPT DISPLAY ALL, TEXT RED);
    fDebug("ARERR [8939] The AR System Plug-In server is not responding.");
      error := false;
    \\
    else
    error := false;
    end;
    verifyErrors := error;
    end verifyErrors;

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*

BMC Helix Innovation Suite 25.2