Forum Discussion

Oferv's avatar
Oferv
Super Contributor
14 years ago

TC can't select from drop down list

TC stop the script from running because it's unable to select value from a dropdown list.

i have a drop down list and i'm trying to simulate a click on one of the drop down values but when TC try to select the value it stop the script from running.

here is the select line code:

Aliases["MainWindow"]["HwndSource_ChooseTemplateDialog"]["ChooseTemplateDialog"]["Grid"]["ChooseType"]["ChooseTypeScroll"]["ClickItem"](Value to select);

i tried to use a name and an index as the value

any ideas why is that happening?

thanks

10 Replies

  • Oferv's avatar
    Oferv
    Super Contributor
    sorry doesn't solve still have the problem
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    What errors do you have in your log file, if any?



    Something that I've seen happen in the past is that there are non-printing characters either in the drop-down list itself or in the text passed to the list.  If you're using text as the information, you might want to double check that.  As for why indexes aren't working, will need to see what errors you have in the log.
  • Oferv's avatar
    Oferv
    Super Contributor
    here's the message in the report file:



    Total number of items: 8.

    Items: '', '', '', '', '', '', '',
    ''.



    Tested
    object:

    Aliases["DesktopMainWindow"]["HwndSource_ChooseTemplateDialog"]["ChooseTemplateDialog"]["Grid"]["ChooseType"]["ChooseTypeScroll"]

    (Sys["Process"]("Desktop")["WPFObject"]("HwndSource:
    ChooseTemplateDialog", "Please Choose a
    Template")["WPFObject"]("ChooseTemplateDialog", "Please Choose a Template",
    1)["WPFObject"]("Grid", "", 1)["WPFObject"]("StackPanel", "",
    2)["WPFObject"]("ComboBox", "", 1))



    is that help?
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    ClickItem by index should still work using syntax like



    ClickItem(0)




    Note that, for index, it MUST be an integer passed.  If you send



    ClickItem("0")
    , this will not work.



    Other than that, though, from what I can see, there are no "text" values in the combo box as seen by TestComplete.  So, index would be the only way to go on this.  Please verify that, when attempting using an index, you are making sure you're using an integer value and not a string value, integer values should be valued 0 to 7 for the 8 items in the box.
  • Oferv's avatar
    Oferv
    Super Contributor
    Thanks Robert,

    yes i am transferring an integer,i even changed the field format in the excel where the value is coming from.

    but,TC just doesn't perform the selection.

    if i'll record only the value selection and run it it will select properly.

    for example :




    function Test1()

    {

      //Selects the 5 item of the 'ChooseTypeScroll' combo-box.

      Aliases["DesktopMainWindow"]["HwndSource_ChooseTemplateDialog"]["ChooseTemplateDialog"]["Grid"]["ChooseType"]["ChooseTypeScroll"]["ClickItem"](5);

    }



    but if i'll convert my recording to script(which i usually do)and i'll copy the code line to my unit and i'll change the value 5 to 3 for example it won't work
  • Oferv's avatar
    Oferv
    Super Contributor
    Yes i found out that the index i'm sending is sending not as an integer becaseu i just converted it to an integer using StrToInt(NewType) and it's working.do you know how i can make sure a value set in excel is an integer?



    thanks
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Personally, I've found that a best practice is to make sure all your data in the Excel sheet is a string.  Makes it a lot easier to standardize the file.



    From there, using StrToInt or VarToInt are the best rules that I've found that, if you want to make sure a data value from the spreadsheet is treated as an integer, explicitly convert it.
  • Hi,

    I am also facing a similar problem. I am writing the script for a web page manually in JavaScript using Name Mapping. There is a part where TestComplete has to select a value from a drop down list.

    First i tried using the text and later using the index. When i am playing it back TestComplete is not throwing any error but its not selecting any value from the drop down list. Thats why i'm unable to write the script further, because if i write next step, Test Complete is throwing the error for that previous step.



    Here are the lines of code:

    1. Using Index:


    Aliases.browser.selectMaincontentDdlcustomrname.ClickItem(2);


    Aliases.browser.selectMaincontentDdlcontactperso.ClickItem(1);



    2. Using Text


    Aliases.browser.selectMaincontentDdlcustomrname.ClickItem("AMERICAN CONSULATE");


    Aliases.browser.selectMaincontentDdlcontactperso.ClickItem("FAYAZ HUSSAIN");



    Do you have a solution to this?