Forum Discussion

vjecov's avatar
vjecov
Occasional Contributor
8 years ago

Keyword Tests: create an object by concatenating variables or parameters

I have the path below:

 

Sys.Process("InteleRIS").WinFormsObject("mdiRIS").WinFormsObject("MdiClient", "").WinFormsObject("frmPatientMain").WinFormsObject("tabPages").WinFormsObject("UltraTabPageControl23").WinFormsObject("pnlApptRequests")

 

 

Now, this is used within a small  keyword test which is called from other test cases.

The last part of this path (the bolded one) should be a parameter which I am throwing in when I call this test.

So basically because this value is dynamic, I need to create an object by concatenating the path with a parameter in the last part of it and then use this object to do different actions on it, like IsVisibleOnScreen.

 

 

I have tried something like next (but it does not work, tried with Variables and Parameters as well):

 

Sys.Process("InteleRIS").WinFormsObject("mdiRIS").WinFormsObject("MdiClient", "").WinFormsObject("frmPatientMain").WinFormsObject("tabPages").WinFormsObject("UltraTabPageControl23").WinFormsObject(" + KeywordTests.PatEdit_CheckCorrectTabIsDisplayed.Parameters.ExpectedPatientEditTabName + ")

 

Please suggest.

 

Note: I need this as a keyword test (but I don't mind a VB script example as well)

 

Thank you.

  • Not quite... I would change the settings on "Call Object Method".

     

    For PropNames, I'd use WinFormsControlName

     

    For PropValues, you can set the type to a "Test Parameter" and then grab your parameter directly. See screenshot:

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    You can do what you're asking by using the Run Code Snippet keyword action if you want to do the concatenation way of doing things.

    You could also use the FindChild method off of the parent object (in your case UltraTabPageControl23) using the Call Object Method  operation and drop a parameter into the value field for the property you're searching for (I'm assuming it's WndClass).

    Probably, though, the easiest way to do this is create a real quick helper function that takes a parameters of the initial path, the string for what you're looking for, and returns the object.  I'm not a VB guy, but here it is in JavaScript... hopefully you can adapt.

    function returnObject(pathString, findString) {
        return eval(pathString + '.WinFormsObject(\'' + findString + '\')')
    }

    This function will return the object that you want... you would then use "Last Operation Result" in your next keyword operation to obtain the object and do whatever you want to with it.

    • vjecov's avatar
      vjecov
      Occasional Contributor

      Thank you tristaanogre - this looks to be quite close to what I am looking for. Could you please see the image below and let me know if that is something related to what you've suggested.

       

      Note: this Operation Parameter (in the image) is applied to:

      Sys.Process("InteleRIS").WinFormsObject("mdiRIS").WinFormsObject("MdiClient", "").WinFormsObject("frmPatientMain").WinFormsObject("tabPages").WinFormsObject("UltraTabPageControl23")

       

      with FindChild method.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Not quite... I would change the settings on "Call Object Method".

         

        For PropNames, I'd use WinFormsControlName

         

        For PropValues, you can set the type to a "Test Parameter" and then grab your parameter directly. See screenshot: