Forum Discussion

vthomeschoolmom's avatar
vthomeschoolmom
Super Contributor
6 years ago

Keyword operation script extension not adding info to keyword test editor

I am writing a script extension for my team's use. When I use the jkeyword test operation defined by the script extension, I see my user form as expected. But when I click OK, nothing is added to my keyword editor workspace page. I am following this tutorial page

 

https://support.smartbear.com/testcomplete/docs/working-with/extending/script/tutorials/creating-keyword-test-operations/defining-editor-contents-and-behavior.html

 

I think I am seeing that this segment

 

			<Columns>
				<Column Name="Item" Value="VSI Standard Startup" />
				<Column Name="Value" GetValue="StartingSegment_GetValue" />
				<Column Name="Description" GetValue="StartingSegment_GetDescription" />
			</Columns>

of the description XML is supposed to identify what goes in the columns. And this code

 

function StartingSegment_GetDescription(Data)
{
	return Data.Description;
}

function StartingSegment_GetValue(Data)
{
  	return Data.QACompleteInfo;
}

Where Data is comnig from the values of my user form

 

function StartingSegment_OnSetup(Data) {

    var frm = UserForms.ssEditForm;
    // Display the Operation Properties dialog and check the results
    if (frm.ShowModal() != mrOk) return false; // No changes were made

    Data.QACompleteInfo = frm.txtNameId.Text;
    Data.PreReqText = frm.txtPreReq.Text;
}

Can anyone advise as to what I am doing wrong? THANKS!

  • What do you have set up in your OnClick handler for your OK button?  That is where the mrOK value should be set for the show modal.  So, once the OK button is clicked, the form "ModalResults" property should be set to mrOK.  If that's not happening, then the form closes but it might not have the proper value and the "return false" executes and none of the rest of the data shows.

     

    That's a rough guess but that's where I 'd start.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    What do you have set up in your OnClick handler for your OK button?  That is where the mrOK value should be set for the show modal.  So, once the OK button is clicked, the form "ModalResults" property should be set to mrOK.  If that's not happening, then the form closes but it might not have the proper value and the "return false" executes and none of the rest of the data shows.

     

    That's a rough guess but that's where I 'd start.

    • vthomeschoolmom's avatar
      vthomeschoolmom
      Super Contributor

      In the form desgner, I have ModalResult = mrOk for the OK button, which I am clicking. I see no code in the example. I thought mrOk property was sufficient to say GO! :) I have included the solution as attachment. I have also included the source files for the form, extension code and ...  I am still in the debugging step, so have not yet packed the extension up.

       

      Thanks for your reply. 

      • vthomeschoolmom's avatar
        vthomeschoolmom
        Super Contributor

        More info...  still stuck

         

        function StartingSegment_OnSetup(Data) {
        
            var frm = UserForms.ssEditForm;
            // Display the Operation Properties dialog and check the results
            if (frm.ShowModal() != mrOk) return false; // No changes were made
        		var sFile = "C:\\\VSI Script Extensions\\" + GetRandomString() + ".txt";
        		var iResult = aqFile.Create(sFile);
        		if (iResult == 0)
        		{
        			aqFile.WriteToTextFile(sFile, "YOOOOOO!", aqFile.ctUTF8);
        		}
                Data.QACompleteInfo = frm.txtNameId.Text;
                Data.PreReqText = frm.txtPreReq.Text;
            
        
        }

        I changed the OK code. I can see a file being created with the yo text in it. So... I have something wrong in my description file? 

         

        			<Columns>
        				<Column Name="Item" Value="VSI Standard Startup" />
        				<Column Name="Value" GetValue="StartingSegment_GetValue" />
        				<Column Name="Description" GetValue="StartingSegment_GetDescription" />
        			</Columns>	

        For giggle, I replaced the value an description columns with value and some bogus fixed text. Nuttin.

         

        Thanks again!

    • vthomeschoolmom's avatar
      vthomeschoolmom
      Super Contributor

      The thing that has me baffled is that at one point, the entries were added to the keyword test. At some point in my debugging something else, I cause that behavior to fail. Alas I can't tell what I did wrong. One thing I am 99% sure of is that I did not change the <fields> in the description.xml nor their getdata functions. Well let's say 80% sure since .... I clearly broke something.

  • Vallalarasu_P's avatar
    Vallalarasu_P
    Frequent Contributor

    Have you tried the form values to the project variables and in run time can add those to keyword test.

     

    Project.Variables.MyFirstText = frm.txtNameId.Text;
    Project.Variables.MyFirstText = frm.txtPreReq.Text;

     

    Not Sure, Whether this helps.

     

    Regards

    Valla

    • vthomeschoolmom's avatar
      vthomeschoolmom
      Super Contributor

      That would not do anything to add the items to the keyword editor. Thanks.