Ask a Question

Would like to generalize a table comparison in VBScript

SOLVED
ajb
Occasional Contributor

Would like to generalize a table comparison in VBScript

Working with VBScrip tScripting. I am trying to create a general purpose script to run my browses and compare the output. 

Starting with:

 

Call Tables.SDTCode1.Check

 

I would like to use a parameter for "SDTCode1" so that this script can be generalized and used for all browses with just a change to the parameter containing the Table name. Tried a few different things but I must be missing something fairly easy. Any suggestions?

1 ACCEPTED SOLUTION

Accepted Solutions
HKosova
Moderator

Re: Would like to generalize a table comparison in VBScript

You could use Execute to run code as string:

strTableName = "SDTCode1"
Execute("Tables." & strTableName & ".Check")

Or something like this:

strTableName = "SDTCode1"
Set tblCheckpoint = aqObject.GetPropertyValue(Tables, strTableName)
Call tblCheckpoint.Check

 

Or if you want to compare the same table to multiple objects, use the CompareWithObject method instead of Check:

Call Tables.SDTCode1.CompareWithObject(Aliases.MyApp.Object1)
Call Tables.SDTCode1.CompareWithObject(Aliases.MyApp.Object2)

Helen Kosova
SmartBear Documentation Team Lead
________________________

View solution in original post

3 REPLIES 3
tristaanogre
Community Hero

Re: Would like to generalize a table comparison in VBScript

Have you tried using aqObject.CallMethod? What you can do is use a call to FindChild or Find on your "Tables" to find the specific child object, return that object as a varible, and then call the "Check" method.  something like ( am NOT well versed in VBScript so consider this pseudocode):

 

Set MyObject = Tables.FindChild('SDTCode1');
aqObject.CallMethod(MyObject, 'Check')

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
HKosova
Moderator

Re: Would like to generalize a table comparison in VBScript

You could use Execute to run code as string:

strTableName = "SDTCode1"
Execute("Tables." & strTableName & ".Check")

Or something like this:

strTableName = "SDTCode1"
Set tblCheckpoint = aqObject.GetPropertyValue(Tables, strTableName)
Call tblCheckpoint.Check

 

Or if you want to compare the same table to multiple objects, use the CompareWithObject method instead of Check:

Call Tables.SDTCode1.CompareWithObject(Aliases.MyApp.Object1)
Call Tables.SDTCode1.CompareWithObject(Aliases.MyApp.Object2)

Helen Kosova
SmartBear Documentation Team Lead
________________________

View solution in original post

ajb
Occasional Contributor

Re: Would like to generalize a table comparison in VBScript

Thank all of you for your speedy replies. This seemed to work for me in VBScript:

 

strTableName = CompTable
Set tblCheckpoint = aqObject.GetPropertyValue(Tables, strTableName)
Call tblCheckpoint.Check

 

Where CompTable is the parameter containing the name of the Table.

 

Thanks again. Now I can have one script for all our browses changing just the criteria passed in and the appropriate table to compare the output.

cancel
Showing results for 
Search instead for 
Did you mean: