Forum Discussion

james_attree's avatar
james_attree
Occasional Contributor
10 years ago

Using Find() to map the same object causes it to be unobtainabe

I have a wepage, 'a'. On 'a' is a link that goes to webpage 'b'.



I map the link on 'a' by using Find(). This maps it to a variable.



I then call variable.Click() to go to page 'b'.



When I go back to webpage 'a' (later in the test) and I want to click on the same link I am unable to use the previous variable as I get an error 'Unable to obtain item's rectangle'.



I have tried re-mapping the link using the same Find() buy to no avail.



Am I doing something fundamentally wrong?



Many thanks,



James

4 Replies

  • Hi James,

    It could be that the 2nd time there is an invisible control sitting over the top of the link.

    A work around would be to navigate to the URL that the link points to.  For example



    sys.browser("*").toUrl(variable.href)
  • Hi James,



    Adrian might be right about the invisible control.

    Another possible cause is that an index or some other property has changed in the object since you last found it.



    You may just need to run your find again to re-find the object.



    The downside to finds is that they can be slow at times. Especially if you need to keep searching for the same object over and over if it has changed. So far Finds have been more helpful then not.





  • james_attree's avatar
    james_attree
    Occasional Contributor
    Thanks for the replies,



    I may have to use a workaround. I'm confident that there isn't anything blocking the control as I can use the same function in two different tests and in the second one it *may* fail.



    I had an example where I used a test to create a document in our software. I would map this document using a Find and then I would drag it to a trash can. I would then do other tests and then repeat the same one.



    Creates a document, maps it and then I get this error. I have tried clearing the mapping cache with Aliases.RefreshMappingInfo().



    I think it may be a bug with the program and not with my software as the same test worked fine in TC 9.31 =[
  • Hi James,



    I think i may be a bit confused on your use of find and Aliases. In my mind the two are quite different. And in my opinion one is much more helpful and wins where Aliases fails.



    Is this the type of find you are using?

    http://support.smartbear.com/viewarticle/55436/



    If you are then I don't think Aliases.RefreshMapping is going to do anything for you.

    Sys.Refresh() might but I doubt it.



    In my experience, using the Find method as outlined in the link above has found 100% of the objects I have ever come in contact with. 

    I used to use namemapping until i realized it was unreliable in the long run. If something changes you have to modify your name mapping to account for the change. When using the find method I feel my odds are better that if there is a change my find will still located its object.



    So back to my last answer. If you use the find method I have shown in the link above then you may need to run the find each time after you drag that document to the trash can. The reason being that perhaps the index or some other property has changed since you dragged that document to the trash.



    When using the find method you need to choose which properties and values you send to it carefully. I never use the index or any other property that may get modified.