Skip to content

Infragistics Community Forum / Test Automation For Micro Focus Uft Windows Forms / How do you retrieve and set the value of a Combo Box in Ultragrid using QTP

How do you retrieve and set the value of a Combo Box in Ultragrid using QTP

New Discussion
Brian
Brian asked on Jun 14, 2011 2:06 PM

Good morning,

I have a Ultragrid which has a combo box in it. When I record, the value will work with the SetCellData if it is correct. Some of our values have trailing spaces and some do not. I need to get the combo box from the cell. Then I can process the items to see if the specified value is available. If available I can select the value.

Can you tell me how to get the combo box object so I can work with it?

 

Regards,

 

Brian

Sign In to post a reply

Replies

  • 0
    Michael Germann
    Michael Germann answered on May 24, 2011 4:56 PM

      That depends highly on how, where and when the combobox's gets it's data as well as what the combobox actually is. By default, I would say you should be able to use GetNAProperty to get either the cell's or the columns ValueList property, and look at it's ValueListItems. But it is also quite possible that the combobox is a customized editor that doesn't follow that methodology or place of storage for it's data, or that it only populates the combobox on dropdown, and the valuelists are empty prior to that. For the later you can activate the cell, then PerformAction gridEnterEditModeAndDropdown, then try to get the value of the valuelists. If none of those work, I would suggest contacting your developer and learning more about this particular instance of combobox itself.

    As to QTP getting ahold of the specific combobox, in most scenarios the combobox is an editor component and not really a control. In which case QTP has no knowledge of it, as it only interacts with objects that inherit form System.Windows.Forms.Control.

     

    • 0
      Brian
      Brian answered on May 24, 2011 5:29 PM

      Hi Michael,

      Could you possible provide and example of the code to get both the cell and column value list items?

      Thank you,

      Brian

      • 0
        Michael Germann
        Michael Germann answered on May 26, 2011 5:05 PM

        It's been a while, but in looking again the Cell should have a ValueListResolved property that should be viable to use if the ValueList is set on either the Cell or the Column, again it may be necessary to drop down the cell before doing this via PerformAction that I mentioned earlier.

        SET grid = SwfWindow("Form1").SwfTable("ultraGrid1")
        iRow = 2
        sCol = "VL_Column"
        sValListItems = "Rows[" + CSTR(iRow) + "].Cells[" + sCol + "].ValueListResolved.ValueListItems"

        iVLItemsCnt =  grid.GetNAProperty(sValListItems + ".Count")
        sListValues = ""

        For x = 0 to iVLItemsCnt – 1
            sListValues = sListValues + grid.GetNAProperty(sValListItems + "["+cstr(x)+"]") +vbCRLF
        Next
        msgbox sListValues

      • 0
        Brian
        Brian answered on May 26, 2011 6:24 PM

        Hi Mike,

        Here is the code that I used:

        'Activate the cell on the table with the combo and see if we can get the count of the list items
        Set objectTable = SwfWindow("SwfWindow").SwfTable("MyTable")
        rowNumberHeader = 0
        assignedColNumber = 0
        colKeyTextInfo = CommonTMSGetHeaderKey(objectTable, rowNumberHeader, assignedColNumber)

        objectTable.ActivateCell 0, 0
        iRow = 1
        sCol = colKeyTextInfo
        sValListItems = "Rows[" + CSTR(iRow) + "].Cells[" + sCol + "].ValueListResolved.ValueListItems"

        iVLItemsCnt =  objectTable.GetNAProperty(sValListItems & ".Count")
        sListValues = ""

        For x = 0 to iVLItemsCnt – 1
            sListValues = sListValues + objectTable.GetNAProperty(sValListItems + "["+cstr(x)+"]") +vbCRLF
        Next
        msgbox sListValues

        When I run the script, I get the following error message:

        Exception is thrown by the control with the following Error Message:\nIndex was outside the bounds of the array.

        Line (13): "iVLItemsCnt =  objectTable.GetNAProperty(sValListItems & ".Count")".

        Any suggestion on what I might have missed on this?

         

        Thanks,

        Brian

      • 0
        Brian
        Brian answered on May 26, 2011 6:33 PM

        HI Mike,

        I missed a couple of items on the code which needed to be update. The "+" needed to be "&" in order to get value to come out. I am geting the long description value but I also need the short description. In other combo boxes as and example the displayed value is "" and the description is "None". The two values are needed.

        Here is the updated code.

        'Activate the cell on the table with the combo and see if we can get the count of the list items
        Set objectTable = SwfWindow("SwfWindow").SwfTable("MyTable")
        rowNumberHeader = 0
        assignedColNumber = 0
        colKeyTextInfo = CommonTMSGetHeaderKey(objectTable, rowNumberHeader, assignedColNumber)

        objectTable.ActivateCell 0, 0
        iRow = 0
        sCol = colKeyTextInfo
        sValListItems = "Rows[" + CSTR(iRow) + "].Cells[" & sCol & "].ValueListResolved.ValueListItems"

        iVLItemsCnt =  objectTable.GetNAProperty(sValListItems & ".Count")
        sListValues = ""

        For x = 0 to iVLItemsCnt – 1
            sListValues = sListValues + objectTable.GetNAProperty(sValListItems & "["& cstr(x) & "]") & vbCRLF
        Next
        msgbox sListValues

        Thanks for your help,

         

        Brian

      • 0
        Michael Germann
        Michael Germann answered on Jun 2, 2011 4:24 PM

        Hi Brian,

        I am not sure of how you mean with your distinction between short description and long description as those are not properties of a ValueListItem, and your developer may be getting them from any number of places.

        I would try both DisplayText and DataValue as these are most likely.

        So in code either :

        sListValues = sListValues + objectTable.GetNAProperty(sValListItems & “[“& cstr(x) & “].DataValue”) & vbCRLF

        or

        sListValues = sListValues + objectTable.GetNAProperty(sValListItems & “[“& cstr(x) & “].DisplayText”) & vbCRLF

      • 0
        Brian
        Brian answered on Jun 2, 2011 5:17 PM

        Hi Michael.

        I tried to DataValue: sListDispValues = sListDispValues & objectTable.GetNAProperty(sValListItems & "["& cstr(x) & "].DataValue") & vbCRLF

        but I get the following error:

        Type 'Summit.Framework.View.DDItem' in Assembly 'Framework, Version=5.30.9245.1139, Culture=neutral, PublicKeyToken=1984b01ba11e2fd5' is not marked as serializable.

        Line (19): "sListDispValues = sListDispValues & objectTable.GetNAProperty(sValListItems & "["& cstr(x) & "].DataValue") & vbCRLF".

        The value returned by the original code: sListValues = sListValues & objectTable.GetNAProperty(sValListItems & "["& cstr(x) & "]") & vbCRLF

        And the new for DisplayText: sListTextValues = sListTextValues & objectTable.GetNAProperty(sValListItems & "["& cstr(x) & "].DisplayText") & vbCRLF

        Both return the value is the list here are some examples

        Displayed Value after selection

        Displayed Description in List

        "" or Empty String value

        None

        SECID

        Security ID

        ABI

        ABI(Italy)

         I need to select by the Displayed Values for some columns and the Description for others. The text is coming from the database and is dynamic. Sometimes we get extra spaces which is why I need to get the value.

        In other combo elements I get a singe value such as "";None, or SECID:SecurityID.

        Let me know if this clears things up.

        Regards,

        Brian

      • 0
        Michael Germann
        Michael Germann answered on Jun 3, 2011 3:07 PM

        You will likely have to ask your developer about Type 'Summit.Framework.View.DDItem', as this is likely a value type specific to them. The exception "is not marked as serializable" basically means it's a custom data type, that was not made in a way to be passed out of the .NET framework cleanly. GetNAProperty can dig into it further as it is doing so while still in the .NET framework and return a serializable property value from it. Likely in your case you are looking for a string value. Your developer should know the property names of that object and which one is the one you should use.

        If you are using TestAdvantage 10.3 or later, you can use the GetNAProperties method, which is used similarly to GetNAProperty, but instead of attempting to return the value of the property of the name you supplied, it instead returns all of that available property names and their datatype names, off of the property value of the name you supplied.

      • 0
        Brian
        Brian answered on Jun 8, 2011 1:14 PM

        Hi Mike,

        I spoke to the person I work with on this project. Laurie recalls that we could not use the 10.3 advantage on the application since the company used a earlier version of the toolkit to build the code. Can we install the 10.3 to get the information and then use this in the 2007 toolkit code in
        QTP.

        Thank you for your help,

        Brian

      • 0
        Brian
        Brian answered on Jun 8, 2011 4:16 PM

        Hi Michael,

        Here are the versions of the DLLs which are in the appliation directory.

        Can we use the TestAdvantage 10.3 with this version of code?

        Regards,

        Brian

      • 0
        Michael Germann
        Michael Germann answered on Jun 8, 2011 5:06 PM

        Hi Brian,

        Unfortunately no, you need to use the version of TestAdvantage with an identical Major and Minor assembly version number, and CLR. So in your case you would need to use TestAdvantage 7.3 since you are using NetAdvantage 7.3.

        GetNAProperties is only really an exploratory method to help learn more about the property names and their data types. It’s useful for testers who may have limited access to their developers and want more information on the fly. If you do have access to your developer it should be easier to ask them what that datatype is and what properties it has.

        If for some reason that is not a viable option for you, there are other methods. Albeit they will require a greater amount of understanding of code. You could use .NET Reflector, have it open your application, then find the data type that you are looking for.

        According to your previous entry in the forums, you would need to expand the references of your application, right click on the reference to Framework, and select Go To Assembly. Find that assembly, which hopefully should be either in the directory of your application or it’s bin directory. If you find that assembly, then you can search for it via F3 or View-> Search to search for “Summit.Framework.View.DDItem”, double click it in the search window to highlight it in the main window. Finally right click it and select dissemble. It should open a Disassembler window.

        Use the information that you garner from that to access the data via GetNAProperty. Note that GetNAProperty returns allows you to dig down through public properties. It will only return values of properties for simple datatypes such as string, int, double, datetime, etc.

        As I stated this is a much more advanced method of trying to learn about a particular object, and is why we created GetNAProperties, but as this is not a window open to you, due to versioning restrictions, and if the developer is not available to you, it is at least an additional option.

         

      • 0
        Michael S.
        Michael S. answered on Jun 14, 2011 1:45 PM

        Is there anything more we can help you with?

        Michael S.

      • 0
        Brian
        Brian answered on Jun 14, 2011 2:06 PM

        Hi Mike,

        Thank you for the ideas. We are going to hold off on getting this done for now.

        Regards,

        Brian

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Brian
Favorites
0
Replies
13
Created On
Jun 14, 2011
Last Post
14 years, 8 months ago

Suggested Discussions

Created by

Created on

Jun 14, 2011 2:06 PM

Last activity on

Feb 23, 2026 10:20 AM