Forum Discussion

sanketh's avatar
sanketh
New Contributor
13 years ago

Object Spy displays long line of code

Hi, 

I just started evaluating "code explorer" segment of Test Complete and was successful in completing a simple script.

In this script I am trying to enter few characters in a "Text Box", However the code hierarchy ( Line8 & Line9 ) is too long.




'line1 

Sub Main

'line2

msgbox "Hi"

'line3

If Aliases.browser.Exists Then 

'line4

Sys.Browser("chrome").Terminate

'line5

End If

'line6

Browsers.Item(btChrome).Run

'line7

Sys.Browser("chrome").ToUrl("www.google.co.in")

'line8

Aliases.browser.Page("http://www.google.co.in/").Panel("mngb").Panel("gb").Panel("gbw").Panel("gbq").Panel("gbq2").Panel("gbqfw").Form("gbqf").Fieldset("gbqff").Panel("gbfwa").Panel("gbqfqw").Panel("gbqfqwb").Table("gs_id0").Cell(0, 1).Panel("gs_lc0").Textbox("gbqfq").SetText "India"

'line9

Aliases.browser.Page("http://www.google.co.in/").Panel("mngb").Panel("gb").Panel("gbw").Panel("gbq").Panel("gbq2").Panel("gbqfw").Form("gbqf").Panel("gbqfbwa").Button("gbqfba").Click

'line10

End Sub


Is there any better way of rewriting the above lines of code in test complete?Would it have been different had i used NameMapping?



The same code in QTP would have been as :

'Line8

Browser("Google").Page("Google").Frame("gb").WebEdit("gbqfq").Set "India"

'Line9

Browser("Google").Page("Google").Frame("gb").WebButton("gbqfba").Click 





Thanks & Regards

Sanketh Shanbhag




3 Replies

  • Hi Sanket,

        1. Try"Extended Find" and "Conditional Find" in Named Mapping

        2. Script Method: Use FindAllChildren



    ~Nagaraj Mali

    ~Pune- India
  • Anonymous's avatar
    Anonymous

    Hi Sanketh,



    The NameMapping feature will reduce the recorded test. TestComplete provides many ways to access a web page, so you can choose the one most convenient for you. Go through the "Finding Objects on Web Pages" article.