Forum Discussion

kroe761's avatar
kroe761
Contributor
11 years ago

Getting "object doesn't support this property or method" - doesn't make sense?

I am writing web tests using JScript and have several files.  At the top of the main test I am running, I include //USEUNIT plus the file I am importing.  The file I am importing is basically just a mapping script consisting of various buttons, fields, etc for a particular page.  The test I am running checks an internal tab on a CRM page, checks the value, submits, and then clicks the same tab and see if any changes are made.  When I click the tab the first time, it works, but COPYING the code for the when I click it the second time, I get the MS JScript error "object doesn't support this property or method."  How can tihs be?  Basically, it's this 



//USEUNIT my_mapping



function testing()

{

  // code..



  obj = my_mapping.object()

  obj.Click()



  // more code...



  obj = my_mapping.object()       //<-here is where I get the error

  obj.Click()



  // more code...

}



If my code just didn't work, or the object couldn't be found, then it would fail in the object() method, but why is TC saying my_mapping doesn't support the object() method when it just worked prviously?  



Also, when I copy the code out of the function and use it by itself instead of calling the my_mapping.object() method, it works with no problems, so it's not my code, at least not that I can tell.



Addiotinally, if I copy the function to the main file, and run it that way (like, instead of my_mapping.object() I would just call object() ) it works with no problems.  



This is really weird.  Thanks!

2 Replies

  • NisHera's avatar
    NisHera
    Valued Contributor
    There could be two possibilities

    The first time you excute  "obj = my_mapping.object()"

    you get exact what you want, but in your "  // more code..." you manupulate screen so that 

    1) "Click() " method is not available at that time  or



    2)  another object appear, that could be return by " my_mapping.object()" in other words another object with same mapping has emerged by " // more code..."



    I think most problably case 1 , if your abject take time to drow on screen



  • nebti_nassim's avatar
    nebti_nassim
    Occasional Contributor


    Are you really sure that your my_mapping.object() point to your object for which you try to call the Click() method ? As you explain your problem it seem that you object support the click() method but your my_mapping.object() not, so we can assume that maybe your mapping properties for this object can return several objects or to another object and that when you call the click() method, the method is called on a different object that doesn't support the method.



    To validate this theory, you can try to highlight your control from the mappedName file and see what TC return to you.