Forum Discussion

todd2's avatar
todd2
Contributor
6 months ago

TestComplete Combox problem

Does anyone have a suggestion on how to handle the phenomenon of a combo box being selected but not getting let go so that the next one can be chosen and its item selected strictly in keyword test built in provided methods not requiring code at all?

 

What I am seeing is a box will drop down the item wont select and the menu just sits there as if stuck unless I interact with the AUT by clicking anywhere on the form.

 

-todd2

7 Replies

  • Oh and to rrhagvi and if spelled your name wrong please forgive me in advance.  YOu ask me repeatedly if I could or why cant I upload images.  I work in an environment that precludes me for having the authority to do such a thing.  I have to find an example elsewhere of the TestComplete behavior and apply a recommended solution to it to alleviate the problem.  I wish there was a keyword step that was setfocus and unset focus and wait not delays.

     

    -todd2

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Remember, not all controls are the same, even though they may look the same, their behaviour may be different. A combobox such as https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select you can use ClickItem method. I'm not sure if using keyword test, ClickItem method will work. Some have reported it as an issue.

     

    Otherwise you will have to perform a click to expand the dropdown list, then perform another click to select the item.

     

    • todd2's avatar
      todd2
      Contributor
      Yes sir, that is correct. That is exactly the box in this question. Yes,
      I want to follow the SmartBear TestComplete documentation to work with
      combobox controls and it is apparent that SmartBear deprecated ClickItem
      for Xpath CSS shops like us. I don't even see a doc where in code I could
      select the span tag item and point it to my spreadsheet column data to then
      select that item in the dropdown based on the spreadsheet datasource. I
      had everything ready to go with ClickItem but now it's foreign to me.

      I have code from SmartBear they gave me to run in a unit script dropped
      into my keyword test but it leads sometimes to flaky results. I wanted to
      expand on their code I guess because ClickItem is deprecated to click the
      control, then choose the item based on the datasource column and row that
      is in the data loop.

      Was hoping to find a video on that and i cant seem to find one. Do you
      know of one? Do you know of code that does that.

      And thank you in advance for your help as always.

      -todd2
  • rraghvani's avatar
    rraghvani
    Champion Level 3

    This is the definition of a wildcard.

     

    You are providing exact instructions to TC, to select an item called 'Audi'. If you select an item e.g. using '*udi', 'A*di' or 'Au*i' etc, it will not work.

     

    For example, if you have a spreadsheet with a list of vehicle names, then you implement data-driven. You extract the first data (vehicle name) from the spreadsheet, pass this to a function which then selects that vehicle from the list e.g.

     

    function SelectItem(vehicle)
    {
        ...
        var listbox = page.FindElement("//select[@id=(//label[.='Choose a car:']/@for)]");
        listbox.ClickItem(vehicle);
    }

     

    The second loop, will then read the second data from the spreadsheet pass this to a function which then selects that vehicle and so on.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    ClickItem method is not deprecated. 

     

    Here's a simple example,

    function SelectItem()
    {
        var page = Sys.Browser("chrome").Page("https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select").FindElement("#iframeResult");
        var listbox = page.FindElement("//select[@id=(//label[.='Choose a car:']/@for)]");
        listbox.ClickItem("Audi");
    }

    I use FindElement with the XPath query, followed by ClickItem to select 'Audi'

    • todd2's avatar
      todd2
      Contributor
      Can Audi be a wildcard and then that will fill in from the spreadsheet
      value somehow

      Todd2
  • Another user in another thread mentioned my problem and wanting to pull the answer from a spreadsheet.  How can I set Audi to be a wildcard and let data loop spreadsheet source drive that spot so all your code will work right to the wildcard which will grab the value from the spreadsheet?  Sorry if too wordy but I am trying to express what I want in laymen terms  I have the label id now i want the clickitem to be the spreadsheet column and row from the data loop spreadsheet source like I see in Lino video on Orders in YouTube from 12 yeArs ago.

     

    -todd2