Forum Discussion

geethwind's avatar
geethwind
Contributor
13 years ago

Eval() is not getting recognized in Test Complete

I have a VBScript function which checkes whether the Window exists are not with the following code


strWindow = Browser(""title:=.*"","CreationTime:=0")

set asd(0,1) = Eval(strWindow)


 When i execute this code in test complete, i am getting the error



Microsoft VBScript runtime error

Type mismatch:'Browser'



How can i fix this? is there any similar function to Eval in Test complete , this code works properly in my QTP script . I even tried Execute method, but that doesn't help too..



can anybody suggest me a way out?



Thanks,





9 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Geeth,



    TestComplete and QTP use different test object models, and QTP scripts are generally incompatible with TestComplete.

    To see how TestComplete identifies applications, windows and objects, you can use the Object Browser.



    If you need to check if the web browser is running, you can use the following code in TestComplete:

    If Sys.WaitProcess("iexplore").Exists Then

      ' IE is running

    Else

      ' IE isn't running

    End If


    Or, using Eval:

    strIE = "Sys.WaitProcess(""iexplore"")"

    Set ie = Eval(strIE)



    If ie.Exists Then

      ' IE is running

    Else

      ' IE isn't running

    End If


    Here're also some links to TestComplete web testing resources that you may find useful:

    Intro to Web Testing (video)

    Verifying Values of Web Page Elements (video)

    Automating Tests of Web Applications (webinar recording)

    Testing Web Applications Tutorial

    Testing Web Applications (help docs)

    Functional Testing of ASP.NET Web Pages With TestComplete (article)
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Geeth,



    As a parameter Eval() requires a string containing any legal VBScript expression.

    So I would try something like this:

    strWindow = "Browser("""title:=.*""","""CreationTime:=0""")"



    set asd(0,1) = Eval(strWindow)
  • This gives me a syntax error



    Set astr(0,1) = Eval("Browser("""title:=.*""","""Creationtime:=0""")")




    I even tried assigning



    strVal = "Browser("""title:=.*""","""Creationtime:=0""")"

    set astr(0,1) = Eval(strVal)



    but the same syntax error occurs..
  • scsvel's avatar
    scsvel
    Frequent Contributor
    Hi Helen,



    Is the VBScript will work which is mentioned above? Its like QTP DP format. Is the same format will work in TC using Eval like Alex told above?



    Thanks...
  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Shanmugavel,



    No, the test object addressing syntax used in QTP descriptive programming is not compatible with TestComplete.

    TestComplete uses a different object addressing syntax, for example:

    Sys.Process("ProcessName").Window("WindowClass", "Window Caption")


    For more details, please read about object naming in the online help.
  • Helen



    Thanks ..its working if i use the below code to check any IE window opened or not.



    strIE = "Sys.WaitProcess(""iexplore"")"

    Set ie = Eval(strIE)



    -Geeth
  • ram_j's avatar
    ram_j
    New Contributor
     

    Eval in Test complete is not working for particular object



    value of   dtObjectmap.Value(2)  =  Sys.Process("Printgroove POD Ready").Dialog("Printgroove POD Ready")  and it is taken from excel sheet using DDT.ExcelDriver



    set GetObjectMap =  eval(dtObjectmap.Value(2)) ' in this point while we fetch the above object TC hanges and waits still for infinite time



    pls suggest me a way out
  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Ram,


     


    Eval should obtain a string. Look at samples posted by others above.


     

  • ram_j's avatar
    ram_j
    New Contributor
    While fetching object from Excel sheet usind excel driver we need not provide quotes.



    only while we pass object directly in script (Hard coding objects) we have to use quotes.