Forum Discussion
Hi again, I hope you'll be able to see the screenshots this time.
In screenshot #1 I have created a new project and named it TESTCONTROL1000 (the name could be whatever combination of letters and numbers).
When I finish recording my test and re-run it, it will fail because the new project isn't allowed to have the same name as the previous project. I've therefore tried to enter a code expression (see screenshot #2) through which every new project created whenever the test is re-run, is named by the date and time of its creation.
So far so good, but I need to capture the value of the project name as I need it in the test steps to come.
Thus, the project name should be the same throughout the entire test but change whenever the test is re-run.
#1 approach
I've tried to capture the project name value (the date/time expression) in a variable by opening the created project in my app after recording and capturing the name value as a property object/onscreen onject. I then used the variable whereever the project value should be inserted further on in the test procedure. Unsuccessfully.
#2 approach
As the project name could be whatever my next approach was to create a simple Excel data sheet with a list of test project name values and saved it as a csv file. I created a data sheet variable and used it in my test in the same way as described in #1 approach. Problem arised as the variable value didn't appear to change from the first data sheet value to the second to the third with each test run.
Now I've run out of ideas and am beginning to doubt whether this is actually possible in TestComplete - preferably without coding - and I hope you can offer some advice. Let me know if you need further info or screenshots.
Thank you very much in advance.
Your code expression is incorrect. What I would suggest is give it a starting static piece of text to identify it as coming from your automation and then the datetime stamp to make it unique. It SHOULD be something like this.
'Automation' + aqConvert.DateTimeToFormatStr(aqDateTime.Now(), '%Y%m%d%H%M')
Now, what I would ACTUALLY, do is use the Set Variable Value operation in your keyword test, create a variable call "projectname", and assign it the value of the code expression as I indicate above. Then, in that operation in your screenshot, set the "Mode" to "Variable" and select that projectname variable from the drop down. You can then use that variable throughout the keyword test anytime you need to reference the project name.