Ask a Question

How do I use a variable for the connection string in keyword test db table variables in TestComplete

SOLVED
sdouglasb
New Contributor

How do I use a variable for the connection string in keyword test db table variables in TestComplete

I created a project level variable as a string with the value being the connection string I want to use for database queries in all my keyword tests.  The idea being that this way I would only have to change the connection string in one place and it be changed for all queries in all my tests that use it.  This way I can easily run my tests in different environments without having to edit every single test first.

However, I can't seem to figure out how to use the connection string variable in my tests.

For example, in a keyword test, I:

1. click the Variables tab

2. right click then click New Item

3. select Type = DB Table

4. select data source type = Database Query

In the Specify Database Connection Settings window, it will not let me use a variable in the Connection field.

5. click the 3 dots at the right of the Connection field

In the Data Link Properties window, it will not let me use a variable in the Server Name field

6. manually populate connection fields

7. click OK

8. enter query into the Query Text field

9. click Finish

on the keyword test Variable tab, my variable is created, but when I try to edit the Default Value field replacing the connection string with a variable, it does not save.

 

Is it in any way possible to use a project level variable as the connection string for a keyword test DB Table variable?

 

1 ACCEPTED SOLUTION

Accepted Solutions
tphillips
Frequent Contributor

Re: How do I use a variable for the connection string in keyword test db table variables in TestComp

TestComplete supports adding variables to a project/project suite programmatically:
https://support.smartbear.com/testcomplete/docs/testing-with/variables/collections/project-and-proje...

And in Keyword tests:

https://support.smartbear.com/testcomplete/docs/keyword-testing/variables.html#Scripts

 


--------------------
Senior SQA Automation Engineer

View solution in original post

7 REPLIES 7
hkim5
Staff

Re: How do I use a variable for the connection string in keyword test db table variables in TestComp

The connection string for DB connections can only be parameterized via variables within script routines, currently not supported by the keyword test operations

Best,
Justin Kim
sdouglasb
New Contributor

Re: How do I use a variable for the connection string in keyword test db table variables in TestComp

Thank you.  How can I write the same type of query via script routine?

Bake1r
Occasional Visitor

Re: How do I use a variable for the connection string in keyword test db table variables in TestComp

I faced similar kind of issue last time, I am still searching for some proper solution tellthebell.

sonya_m
Community Manager

Re: How do I use a variable for the connection string in keyword test db table variables in TestComp

I wonder if community members would have similar examples?

 

@tristaanogre @anupamchampati @Wamboo @Reshail 


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Wamboo
Community Hero

Re: How do I use a variable for the connection string in keyword test db table variables in TestComp

Hi,

 

what exactly do you want to achieve?

 

Do you want to add a variable to TestComplete -> have your login data there and then read it in the database login script?

 

Is it supposed to be encrypted?

tphillips
Frequent Contributor

Re: How do I use a variable for the connection string in keyword test db table variables in TestComp

TestComplete supports adding variables to a project/project suite programmatically:
https://support.smartbear.com/testcomplete/docs/testing-with/variables/collections/project-and-proje...

And in Keyword tests:

https://support.smartbear.com/testcomplete/docs/keyword-testing/variables.html#Scripts

 


--------------------
Senior SQA Automation Engineer

View solution in original post

sonya_m
Community Manager

Re: How do I use a variable for the connection string in keyword test db table variables in TestComp

Thank you for keeping the discussion going!

 

@sdouglasb Did you find a way to this? Please give the Community more details if the articles didn't help.


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: