cancel
Showing results for 
Search instead for 
Did you mean: 

Setting project variable using InputBox

SOLVED
Logiv
Contributor

Setting project variable using InputBox

Hello,

Previously I was able to create a little sript to get the user to input a path at the start of the test, and then grab a EXE version from that path.
My goal was to save the TestComplete Project log with the name of EXE + version at the end of the test.
I realized that I couldn't do it because I was using "normal" variables and they weren't kept in memory.

The help file directed me to project variables. I was able to create one, but I cannot find the structure to get the value of the variable + the user's answer to the prompt.

So previous variable was:
EXEPath = BuiltIn.InputBox("Find EXE path", "Enter EXE Program Files path:", "")

 

Now I am trying things like:
ProjectSuite.Variables.VariableByName["EXEPath"] =
BuiltIn.InputBox("Find EXE path", "Enter EXE Program Files path:", "")

But the second line shows error "Unexcepted TKN_NewLine"


1 ACCEPTED SOLUTION

Accepted Solutions
BenoitB
Community Hero

Re: Setting project variable using InputBox

"ProjectSuite.Variables.VariableByName["EXEPath"] =
BuiltIn.InputBox("Find EXE path", "Enter EXE Program Files path:", "")

But the second line shows error "Unexcepted TKN_NewLine""

 

Is it intented to go new ligne after the = ?

 I don't use PY but according to the error msg i think that you must remove this carriage return and write all on same line :

ProjectSuite.Variables.VariableByName["EXEPath"] = BuiltIn.InputBox("Find EXE path", "Enter EXE Program Files path:", "")

 

Un sourire et ça repart

View solution in original post

5 REPLIES 5
AlexKaras
Community Hero

Re: Setting project variable using InputBox

Hi,

 

The help file directed me to project variables.

ProjectSuite.Variables.VariableByName["EXEPath"] =

The syntax seems to be correct. But the code uses project suite variable but not project variable. Is this correct?

 

One general note: Use of InputBox() method requires human interaction. This means that your test code can not be executed unattended (on schedule, within CI pipeline, etc.). Is is OK and expected?

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
BenoitB
Community Hero

Re: Setting project variable using InputBox

"ProjectSuite.Variables.VariableByName["EXEPath"] =
BuiltIn.InputBox("Find EXE path", "Enter EXE Program Files path:", "")

But the second line shows error "Unexcepted TKN_NewLine""

 

Is it intented to go new ligne after the = ?

 I don't use PY but according to the error msg i think that you must remove this carriage return and write all on same line :

ProjectSuite.Variables.VariableByName["EXEPath"] = BuiltIn.InputBox("Find EXE path", "Enter EXE Program Files path:", "")

 

Un sourire et ça repart

View solution in original post

Logiv
Contributor

Re: Setting project variable using InputBox

Hello,
Yes it is expected, this is why my initial post mentioned the "user's input". 
It is because my test can be ran on several different folders on the computer.
I ask the user first: Which folder you want to test?
I know how to use a specific folder and I do that for machines with a single installation, but not on my own (or my team's) computer where I have about 30 folders to test.

Logiv
Contributor

Re: Setting project variable using InputBox

Merci Benoit.

It is now able to run. I am getting a different error now, but I might be able to figure it out. 

 

The Variables object does not contain a variable with the "EXEPath" name.
But when I go in the project variables, I do see my variable there. I will work on it. Thank you.
Logiv
Contributor

Re: Setting project variable using InputBox

Got it. 
I followed a different structure to set the variable, as found here:

https://support.smartbear.com/testcomplete/docs/reference/program-objects/variables/index.html


New Here?
Join us and watch the welcome video:
Top Kudoed Authors