Forum Discussion

phil_hunter's avatar
phil_hunter
Occasional Contributor
11 years ago

TestComplete is selecting the wrong list item




Hi,



I'm relatively new and I havn't been able to find useful documentation on this, but when I run the automated test, TestComplete selects the wrong list item. 




The list only appears when you click on a box, then the javascript shows the html elements (
the view engine used is Razor with javascript


and ajax). When recording a test, I can choose any in the list (e.g I want to order a cellphone), but when I run the test, TestComplete always selects the last item in the list (I want to order Telephony). I think I have mapped the correct option/link:



 Aliases.browser.pageIsServicePortal.panelBody.sectionContentWrapperMainContent.panel.panelRequestofferingcontent.panelRequestofferingcontent.panelRequestofferinginnercontent.linkServerRo.panelIWantToOrderACellphone



Can anyone tell me why TestComplete is choosing the wrong list item? 



Regards,



Phil




  • Create a new script routine, with "object spy" see the properties of the object you want to click, after that just adapt the code I'm giving below to your needs:




    //function you can call everywhere


    function clickContentTextVisibleOnScreen(text)


    {


    Aliases.browser.pageIsServicePortal.Find(new Array("contentText", "visibleOnScreen"), new Array(text, "True"), 500, true).Click();


    }


     


    //put you mouse cursor here and click the green "play" button on top of the editor


    function main()


    {


    clickContentTextVisibleOnScreen("I want to order a cellphone");


    }

  • jose_pita's avatar
    jose_pita
    Super Contributor
    Create a new script routine, with "object spy" see the properties of the object you want to click, after that just adapt the code I'm giving below to your needs:




    //function you can call everywhere


    function clickContentTextVisibleOnScreen(text)


    {


    Aliases.browser.pageIsServicePortal.Find(new Array("contentText", "visibleOnScreen"), new Array(text, "True"), 500, true).Click();


    }


     


    //put you mouse cursor here and click the green "play" button on top of the editor


    function main()


    {


    clickContentTextVisibleOnScreen("I want to order a cellphone");


    }

  • phil_hunter's avatar
    phil_hunter
    Occasional Contributor
    Hi,



    Yes that done the trick. That was my first taste off adding scripts, this will come in very handy then. Thanks! I love your profile picture btw, gave me a giggle, lol.



    Regards,



    Phil
  • jose_pita's avatar
    jose_pita
    Super Contributor
    You're starting now? Good, keep it up, always think about the future changes you might need to do in your code, create a set of helper functions you can use regardless of the page or browser you're using.



    Here are some examples, the comments you see are parsed using yuidoc, it is important to keep a good documentation over your code so anyone can understand and you don't keep repeating yourself.



    I have more functions but most of the code is in portuguese and now I don't have the time to translate it (yes, i know , i should always code in english... :( ). Beware I just made this gist, not responsible for errors :D.



    Hope I can be of help :)



  • phil_hunter's avatar
    phil_hunter
    Occasional Contributor
    Thanks, some of those helpers look very useful! Much appreciated.