Forum Discussion

gopalmalu's avatar
gopalmalu
Contributor
14 years ago

Can we do descriptive programming

Hi,



Can we do scripting (descriptive programming) with TC if application is not developed ?



Thanks,

Gopal

15 Replies

  • Yes we can! Try this one



    Function Descript()




       Set pg=Sys.Browser("iexplore").Page("*")


       NameProperty = Array("textContent","outerText","Id","tagName") 


       ValueProperty = Array(strPropVal1,strPropVal2,strPropVal3,strPropVal4)


       Set obj=pg.FindAllChildren(NameProperty,ValueProperty,9999999,True)


       obj.Method  



    End Function



    Based on your requirement enter the Name property and their Property value into array.



    Thank you,

    Srini.



     

  • Yes! we need to pass the property values into the function for which property you supposed to search. i just mentioned some property names for understanding purpose you can change it based on your requirement.



    if you want use it as a generic function then we need to start from top level i think so! 



    Thanks,

    Srini.
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3


    (Been in a good and relaxed mood... :) )



    For me the situation is obvious...



    > Set obj=pg.FindAllChildren(NameProperty,ValueProperty,9999999,True)

    This line requests search for *all* objects that meet specified criteria starting from the specified root. I hope that it is clear that the higher the root is in the objects hierarchy the 'more generic' search is. At the same time, the higher the root is in the objects hierarchy the worse search performance is. (Just because even if you need first found object and the sought for object is found in the first branch of the objects tree, the search will not stop until it traverses all search tree.)

    And the optimal balance between the performance and reusability is a matter of a good code architecture (which, unfortunately, is a rare thing nowadays... :(. And is one of the reasons I love tools by SmartBear).



    Just my $0.02... Nothing to argue about :)


    • Everseeker's avatar
      Everseeker
      Contributor

      Does TestCompete support Regex in this context (or at all)?