Results 1 to 4 of 4
  1. #1

    KDT - Dynamic Inclusion of Files

    We are trying to implement a keyword driven aproach with TestComplete 4.

    What we have is a driver script, which reads keywords from an Excel Sheet and loads the appropriate keyword and executes it.

    Each keyword we have is basically a VBScript Class.

    Due to the nature of the implementation, we only know which files to be included on the run-time, so we do not use USEUNIT directive. Instead what we do is to write a function to read keyword source file content and "ExecuteGlobal" it before creating an instance of the keyword.

    What we face up with is that we recieve "Class not found" errors. We are sure that the source code we ExecuteGlobal is executed because we've checked and saw that variables we add to the files are accessible, but not the classes.

    I believe that this is not a core TestComplete problem but it may be a problem related to scripting engine TC uses.

    Did anyone came up with anything similar? Is there a known solution for that?

    Thanks in advance for your posts


  2. #2

    Re: KDT - Dynamic Inclusion of Files

    For the ones who struggle with the same problem, I have found the following thing in http://automatedqa.com/downloads/Doc...stComplete.pdf

    "If you have a VBScript class defined in one unit and you want to create a class instance from another unit, then using the USEUNIT statement is not enough. You also have to create a special routine that will return the desired class instance. For more information, see Supported Scripting Languages - Peculiarities of Usage."

    I will try it and post the result here as well.

  3. #3

    Re: KDT - Dynamic Inclusion of Files

    I tried and it failed [img]/images/graemlins/smile.gif[/img]

    It seems like as long as we do not use USEUNIT statement, we can not call the functions within the files that we take the content and ExecuteGlobal. Basicly as far as I experienced, there's no way to dynamicly include files during run-time.

    We added all the files in our driver script with USEUNIT statements and it seems to work for now. The solution is slow and hard to maintain but at least it works.

    It would be wonderful to have a function call to include a certain file just like including files in any modern scripting language.

    Your suggestions are still wellcome


  4. #4

    Re: KDT - Dynamic Inclusion of Files

    Hi ozay,

    Unfortunately, there is no way to load a script unit at run-time. I have registered your query as a feature request in our database.

    BTW, the following code works fine on my computer:
    <font class="small">Code:</font><hr /><pre>Sub Main

    Set obj = getMyClass
    Log.Message obj.test
    End Sub

    Sub readFile
    Set fso = Sys.OleObject("Scripting.FileSystemObject")
    Set f = fso.OpenTextFile("e:\script.txt", 1) ' 1 - ForReading
    text = f.ReadAll
    ExecuteGlobal text
    End Sub</pre><hr />

    The contents of the script.txt file are as follows:
    <font class="small">Code:</font><hr /><pre>Function getMyClass
    Set getMyClass = New MyClass
    End Function

    Class MyClass
    Dim m_test

    Public Property Get test()
    test = m_test
    End Property

    Public Property Let test(newVal)
    m_test = newVal
    End Property

    Private Sub Class_Initialize()
    m_test = "tteesstt"
    End Sub
    End Class</pre><hr />
    Best regards,
    David - SmartBear Support



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 05:33 PM.

Copyright BetaSoft Inc.