Forum Discussion

lodecesa's avatar
lodecesa
Contributor
2 years ago

ClickItem select another Option

Hi all,

in a script test I'm trying to select a Select Option with the ClickItem function but TestComplete select the Option that is ten positions above the desired one.

 

The script portion is:

 

selectElement.scrollIntoView();
selectElement.clickItem(elementName);

 

The HTML code is

 

<select _ngcontent-yqp-c115="" class="form-select form-select-sm select-dark ng-pristine ng-valid ng-touched" id="id-3">
  ...
  <option _ngcontent-yqp-c115="" id="idOpt-3-24" value="16: 24">
    <span _ngcontent-yqp-c115="" class="select-option-dark">
      Bahamas
    </span>
  </option>
  ...
  <option _ngcontent-yqp-c115="" id="idOpt-3-34" value="26: 34">
    <span _ngcontent-yqp-c115="" class="select-option-dark">
      Bolivia
    </span>
  </option>
  ...
</select>

 

During the test execution the mouse pointer correctly select the Option desired but when the panel of the select is closed the item selected result the wrong item.

 

I do this two times in a script on two long Select and I have the same behaviour.

 

Why does this happen?

 

Thanks

Lorenzo

  • What browser are you using?

    Chrome 115 is out and it may be causing ClickItem issues again
  • jkrolczy's avatar
    jkrolczy
    Regular Contributor
    What browser are you using?

    Chrome 115 is out and it may be causing ClickItem issues again
    • lodecesa's avatar
      lodecesa
      Contributor

      jkrolczy wrote:
      What browser are you using?

      Chrome 115 is out and it may be causing ClickItem issues again

       

      That was the problem!

       

      Thanks

      • jkrolczy's avatar
        jkrolczy
        Regular Contributor

        Did you open up a ticket with support so this can be addressed in the next update of TestComplete ?

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Here's example code using website https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select

     

    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");
    }

     

    that correctly selects item Audi from the drop down list.

     

    The only issue with ClickItem method, is that it iterates through all items - I've reported the issue, and hopefully it will be fixed in the next patch.

    • lodecesa's avatar
      lodecesa
      Contributor

      Sorry but this not function for me, the drop down list have several items and ClickItem don't select the correct item.

      I have several Dropdown lists in my page but TestComplete don't work correctly. Don't select the correct Item. I have setted some breakpoints, before execute the command I highlight the Dropdown affected by the command and TC highlight it correctly. When I execute the command (ClickItem) TC select the right Item but when the Dropdown is closed the item that is selected is the wrong one.


      All this behavior is unacceptable

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        lodecesa :

        Hi,

         

        The code and markup that you've provided look to be correct, so I would report a problem to Support via the https://support.smartbear.com/testcomplete/message/ form. Your case seems to be different from the behavior described by rraghvani, but I am not excluding the possibility that they both have the same root. Thus you may mention rraghvani's case in your ticket as well.

         

  • juliemorris's avatar
    juliemorris
    Occasional Contributor

    Hi, I have updated my TC build (15.53.2.7) and Chrome is the latest version (115.0.5790.171) and ClickItem is not working. Any other suggestions?

    • jkrolczy's avatar
      jkrolczy
      Regular Contributor

      Hopefully someone has reported this to SmartBear support provide a fix in the next version of TestComplete. 

      I think we can assume this all works correctly in Chrome 114 but Chrome 115 have again caused ClickItem issues again.

      Seems to be a cycle here when Chrome (Chromium comes out)