Forum Discussion
Hi steventwerd
Hope you are well.
Does the key-value pair change often?
You could check out using stores
see https://support.smartbear.com/testcomplete/docs/testing-with/checkpoints/stores/files/index.html
You could also look at parametrization of your tests and call the required pair values at execution
https://support.smartbear.com/testcomplete/docs/testing-with/parameterizing/about.html
Let me know if this could work
KR
Vinnie
Hi Vinnie,
I'm going on the scenario that the key-value pairs do change often or the values at least do.
The problem with Stores is that it seems to only involves checking and comparing and updating the contents of the file, I just want to use (not check or change) the data in UI tests, similarly to a data-driven loop using Excel but with a text file containing key-value pairs.
The problem with parametrization is that I would have to manually change the data for every test to run with the desired info, I would much rather the variables/data be in a text-file to read from for efficiency.
What I want is to not have to have this long line of code at the beginning of ever script test to get a variable:
function ReadFile(AFileName)
{
const ForReading = 1;
const ForWriting = 2;
const ForAppending = 8;
let FS = getActiveXObject("Scripting.FileSystemObject");
let F = FS.OpenTextFile(AFileName, ForReading);
while(! F.AtEndOfStream){
let s = F.ReadLine();
Log.Message(s);
}
F.Close();
}
- vinniew4 years agoStaff
Hi Steven
Thanks for that,
I am not well phrased on how to work around your scripted workaround.Could the data in the text file be phrased/formatted as a table? then look at using maybe a table variable via Data loop?
If then, choosing only the top row, (1 record from the range) specifying that file and then if the pair values change we update the file instead of the test, would that work or would the effort editing the file still cause issues... ?
- steventwerd4 years agoOccasional Contributor
Hi Vinnie,
Apologies, I see I am making this unnecessarily confusing. The property file has to be a text-file (.txt) for other uses. I know I can read data from the property file using the code mentioned previously. I'm just curious if there is another way to read data from a text-file and store it in a variable without having to put that lengthy piece of code at the beginning of every script. Sort of like making it into an environment variable for all scripts to use.
Thanks.
Related Content
- 10 years ago
- 2 years ago
- 5 years ago
Recent Discussions
- 6 days ago
- 6 days ago
- 10 days ago