Forum Discussion

Semirxbih's avatar
Semirxbih
Contributor
10 months ago

clickItem() is not properly selecting dropdown value

Hey all,

So currently, our organization is utilizing the following stack, which we have to utilize since all of our other tests are running on the same stack:

  • Version: 15.61.1.7 x64
  • Version 121.0.2277.106

For some reason, the clickItem() function in TestComplete is not able to properly select the value that is needed in the dropdown, it keeps selecting a different value.

Demo:

We have our "import_selectConfiguration" function which has the value "GCT_1291_AUTO".








We can see that our "GCT_1291_AUTO" is the 128th index number in our configList.We can see that our ClickItem has the value "GCT_1291_AUTO", but when it goes to select the dropdown value, it chooses an value that is incorrect.Here is the options view in the console.

We have been battling with this issue for a while, so I would like to see what I might be able to do.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Can you create a separate function, just to perform the ClickItem("GCT_1291_AUTO") ?

    Also, what technology does your web application use?

    A number of people are having similar issues, but neither of them have mentioned the technology used. I've tested this against Bootstrap, and standard HTML, and it works fine.

    • Semirxbih's avatar
      Semirxbih
      Contributor

      The web application is built using:
      - Java for the back-end.
      - React for the front-end.
      - This is a spring boot application.

      We are using TestComplete to write BDD tests using JScript.

      • rraghvani's avatar
        rraghvani
        Champion Level 3

        Could you go to https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select and then run the following JavaScript sample,

        function SelectItem()
        {
            var page = Sys.Browser().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");
        }

        Is the correct item 'Audi' selected?

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Did you create a simple function, just to perform the listbox.ClickItem("GCT_1291_AUTO")?

    TC will select the item name shown in the list, and not the value i.e. listbox.ClickItem("356c1d59-20a2-482f-bd88-80a9486980a3");

    • Semirxbih's avatar
      Semirxbih
      Contributor

      I did not convert it to a listBox, but I have an array of configList[i] that loops through and ClickItem does not work in that instance.

      • rraghvani's avatar
        rraghvani
        Champion Level 3

        I don't know the exact name mapping you have given for your control, hence I'm referring it to as listbox. I just want you to perform a very simple action, to perform a click on an item, using the ClickItem method.