Forum Discussion

rhsou123's avatar
rhsou123
Contributor
9 years ago

Settext using VBScript

Hi,

 

Can anyone help me to make this working please:

 

Function Login(browserPath,URL,Username,Password)
Browsers.Item("iexplore").Run URL
Set page = Sys.Browser("*").Page(URL)
Set username = page.FindChild("Username")
if username.Exists then
username.setText  "testc10"
end if
Set password = page.FindChild("Password")
if password.Exists then
password.setText  "testc101"
end if
page.Page(URL).Button("Login").Click

End Function

8 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Basic questions:

    What error messages are you getting in your log? 
    What specifically is not working in what you have?

     

    One very important observation:

    The "setText" method is actually "SetText". IIRC, VBScript is case sensitive do that MIGHT be your big problem right there.

    • rhsou123's avatar
      rhsou123
      Contributor

      And if I use this way:

       

      Function Login(browserPath,URL,userName,Password)
      Browsers.Item("iexplore").Run URL
      Set page = Sys.Browser("*").Page(URL)
      page.Username.SetText "testc101"
      page.Password.SetText "testc1011"
      page.Page(URL).Button("Login").Click
      End Function

      Testcomplete waits long time for userName and then it exits.

       

      this is my page:

       

       

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Please review the documentation on using "FindChild".  

         

        https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-all/findchild-method.html

         

        The number of parameters used is more than just a single field. For FindChild, you pass in two arrays, one of property names, one of property values. You also can indicate the depth of the search as an optional parameter as well as a refresh option.

        Recommendation:

        Map your objects under name mapping. Then, instead of "FindChild", you can "telescope" your object tree to something more meaningful like:

        Aliases.browser.pageLogin.textUserName

         

        And then reference these items directly. As it is, most likely the UserName field is not a direct child of the "Page" object but is more likely buried a bit deeper in the tree of objects and containers.  Again, a good recommendation for getting started with TestComplete and your application under test is to record your actions and then, after you have completed the recording, make modifications, etc., based upon how TestComplete discovered your objects, components, etc.