Forum Discussion

ray_mosley's avatar
ray_mosley
Frequent Contributor
13 years ago

Text Entry Playback error - WHY?

In both the examples below, the .jpg was taken after the aqUtils.Delay statement.





The following snippet of code fails: (see attached file *_Exclamation):

Aliases.emdsTaskMan.fmMsgNewMail2.pnBottom0.Panel3.moMessage.Click(9, 18);

qa_InitProjectVariable("taskman_MsgResponseText","I got your message. LEAVE ME ALONE!");

Aliases.emdsTaskMan.fmMsgNewMail2.pnBottom0.Panel3.moMessage.Keys(qa_GetProjectVariable("taskman_MsgResponseText"));

aqUtils.Delay(1500,_msg);




When modified to be a longer string that ends in a period, it works (see the *_Period attached file):



   Aliases.emdsTaskMan.fmMsgNewMail2.pnBottom0.Panel3.moMessage.Click(9, 18);

   ////qa_InitProjectVariable("taskman_MsgResponseText","I got your message. LEAVE ME ALONE!");

   qa_InitProjectVariable("taskman_MsgResponseText","I got your message. LEAVE ME ALONE. I am on break.");

   Aliases.emdsTaskMan.fmMsgNewMail2.pnBottom0.Panel3.moMessage.Keys(qa_GetProjectVariable("taskman_MsgResponseText"));

   aqUtils.Delay(1500,_msg);



I cannot understand why. The project variable is used only here and where it is checked (see below):

      var _ciMainFrom = Aliases.emdsTaskMan.fmMsgMessage.pnBase.Panel5.pcTaskMan.tsMessages.Panel3.rgdMessage0.GetCells(5,1).Text;

      var _ciMainSub = Aliases.emdsTaskMan.fmMsgMessage.pnBase.Panel5.pcTaskMan.tsMessages.Panel3.rgdMessage0.GetCells(6,1).Text;

      var _ciDetailFrom = Aliases.emdsTaskMan.fmMsgMessage.VCLObject("lbFrom").Caption;

      var _ciDetailSub = Aliases.emdsTaskMan.fmMsgMessage.VCLObject("lbSubject").Caption;

      var _ciResponseText = Aliases.emdsTaskMan.fmMsgMessage.pnBase.Panel5.pcTaskMan.tsMessages.Panel3.pnlMessageViewer.VCLObject("moMessage").wText;

      var _ciMsgCount = Aliases.emdsTaskMan.fmMsgMessage.VCLObject("lblTotalMessages").Caption;

      _pos1 = aqString.Find(_ciMainFrom,qa_GetProjectVariable("taskman_provider2_Last"),0,false);

      _pos2 = aqString.Find(_ciMainFrom,qa_GetProjectVariable("taskman_provider2_First"),_pos1 + 4,false);

      _pos3 = aqString.Find(_ciMainSub,qa_GetProjectVariable("taskman_MsgSubject"),0,false);

      _pos4 = aqString.Find(_ciDetailSub,qa_GetProjectVariable("taskman_MsgSubject"),0,false);

      _pos5 = aqString.Find(_ciResponseText,qa_GetProjectVariable("taskman_MsgResponseText"),0,false);

      _pos6 = aqString.Find(_ciMsgCount,_msgCount1,0,false);

      if (_pos1 < 0 || _pos2 < _pos1 || _pos3 < 0 || _pos4 < 0 || _pos5 < 0 || _pos6 < 0 )

      {

         errCount++;

         _msg = _msg + "; ***Message not verified in Completed Items folder***";

      }



The variable _pos5 is negative when the ending character is ! (entire string could not be found, thus -1) but works when it ends in a period.  I added the delay and even tried escaping the exclamation.

6 Replies


  • Hi Harlan,


     


    What does the qa_InitProjectVariable function do? Can you post its body here?


    Also, please describe what exactly fails. Is anything specified in the text area when executing the test?


     

  • ray_mosley's avatar
    ray_mosley
    Frequent Contributor
    I have already tried to explain what happened.  I tried to replay the script using text that ended in an exclamation point character.  It failed the match for variable _pos5 and failed by increasing the error count variable. It matched correctly when I changed the text that did not end in exclamation.  It is a failure in aqString.Find, as described in the final sentence of the original post.  In has nothing to do with the function below.





    Here is the function and its description:





    /*

    Function qa_InitProjectVariable

       initialize the value of a TestComplete Project variable

    --preconditions

       NA 

    ---Parameters

       NA

    --postconditions

       project variable has value

    --returns

       NA

    --NOTE:

       (1) It is the user's responsibility to use/save the returned string

    */

    function qa_InitProjectVariable(vname,value)

    {

        if (!Project.Variables.VariableExists(vname))

        {

           //create the initial variable

           Project.Variables.AddVariable(vname,"String");     //empty string:

        }

        //initialize existing variable

        Project.Variables.VariableByName(vname) = value;     //initialize

        return;

    }

    //END OF function qa_InitProjectVariable

  • rgratis's avatar
    rgratis
    Frequent Contributor
    Have you escaped the exclamation point in the variable for Keys by doubling it?



    You'd have to escape the exclamation point in the call for Keys only, so something like:

    Aliases.emdsTaskMan.fmMsgNewMail2.pnBottom0.Panel3.moMessage.Keys(aqString.Replace(qa_GetProjectVariable("taskman_MsgResponseText"), "!", "!!"));



  • ray_mosley's avatar
    ray_mosley
    Frequent Contributor
    Read the original post - last line.  Yes, I did try escaping the exclamation.
  • ray_mosley's avatar
    ray_mosley
    Frequent Contributor
    Thanks.  That explains it.  Thanks for perervering with the issue.