Forum Discussion

RichBopp's avatar
RichBopp
Contributor
7 years ago
Solved

KeyWord Mode: Is there a way to force a specific option to be selected from a drop down list?

I have a drop down list for selecting Shipping Company.  Depending on the customer, the options available can be different, thus the positions of those they have in common are in different places on the drop down list.

 

I need to select the same Shipper option regardless of where it is listed in the drop down.

 

My KeyWord recording is selecting the Cell range regardless of the value that resides there.  So Cell_1 is "Shipping Company 001" for one customer, but for another it is "Shipping Company 002".

 

 

One of our developers provided me with the following information regarding the design of the drop down:

 

It is a custom designed control consisting of DIV's, TABLE's, and Javascript.

 

Clicking to expand the entry runs onComboArrowImageClick() which, on the first click, POST's the page back. It then reloads with all of the data displayed. Subsequent clicks run the same function, but it just toggles the visibility.

 

Clicking on a row runs tableRowClick(row) which copies that row's values into some hidden fields and updates the display before POSTing the page back if there was a change. This function is passed the <TR> object that was clicked.

 

Is it possible to force the selection made to be the same regardless of where it is located in the drop down?

 

 

  • RichBopp's avatar
    RichBopp
    7 years ago

    Martin/Cuncerw,

     

    Devin over at SmartBear Customer Care came up with a NameMapping option that worked for me, and I wanted to share.

     

    The recorded identifiers were:

    -ObjectType: "Cell"
    -RowIndex: "2"
    -ColumnIndex: "0"

     

    By changing them to the following:

    -ObjectType: "Cell"

    -textContent: "Freight Collect"

     

    I was able to get it to work for me for all customers I wished to test against.

     

    Thank you for your advise,

     

    Rich

     

     

3 Replies

  • cunderw's avatar
    cunderw
    Community Hero

    You could create a utility script that loops through all options and finds one whose text value matches the text you expect and get its index for the item to click. 

     

     

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      cunderw wrote:

      You could create a utility script that loops through all options and finds one whose text value matches the text you expect and get its index for the item to click. 

       

       


      Yup, that's actually probably your best bet given that it's a custom control that is not a "standard" set.  You could attempt to use Object Mapping (https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/improving/mapping.html) to try and map the control to something close to what it is but I suspect that it's not going to work very cleanly there.  As cunderw said, you'll need to work with the properties and fields and methods that are native to the objects and build something custom.

      • RichBopp's avatar
        RichBopp
        Contributor

        Martin/Cuncerw,

         

        Devin over at SmartBear Customer Care came up with a NameMapping option that worked for me, and I wanted to share.

         

        The recorded identifiers were:

        -ObjectType: "Cell"
        -RowIndex: "2"
        -ColumnIndex: "0"

         

        By changing them to the following:

        -ObjectType: "Cell"

        -textContent: "Freight Collect"

         

        I was able to get it to work for me for all customers I wished to test against.

         

        Thank you for your advise,

         

        Rich