Forum Discussion

jfain's avatar
jfain
New Contributor
11 years ago

Page.Find method returns the last object.

I cant find this in the documentation.



I have a list of dynamically created objects (a query table) that all have the same attributes.



I execute Page.Find with the objects attributes expecting the first one to return but the last one returns instead.



This slows the script down allot as there a bunch of results.



Is there a way to force Page.Find to stop searching at the first one?



Thanks.

4 Replies

  • Hi Jason,

     


    I would suggest that you add one more identification property to the method so that it returns one desired object.


     

  • jfain's avatar
    jfain
    New Contributor
    Thanks, but this is a dynamically created web page built from a query.



    For what we are doing (Lights on), we do not need a specific one. Just need to click one. (perferably the first one) As it is dynamic I do not know what the contents will be or they may change. So find works in this situation but it selects the last one. The test would be more efficiant time wise to stop at the first one found and click it.



    I dont know why "Page.Find" wouldnt be designed this way. If I need to go through them all, I would use "Page.FindAll".



    Thanks again
  • Marsha_R's avatar
    Marsha_R
    Icon for Champion Level 3 rankChampion Level 3
    Hi Jason -



    Even though the page is being created on the fly, you may still be able to add a property to narrow down the search.



    Is there an index or something else that uniquely identifies each object?  You can then just search for index = 0 to always get the first one. 
  • jfain's avatar
    jfain
    New Contributor
    Just looked and No, There is not any unique properties aside from the contentText which I can't use.



    Even if I did narrow it down with more properties. Won't Page.Find still search to the end of the document like it does with the properties I do currently input?



    Something is slowing the script down a lot in this part of the test.



    Thanks



    Have a good weekend!