Forum Discussion

AdamUK's avatar
AdamUK
Occasional Contributor
6 years ago

Passwords and loops

Hi, 


I'm trying to log into a site and do various things in a loop.  I need to keep the login information secure. It can't go as plaintext into the project suite and then git so ideally I would use the password variable feature in TestComplete.  

 

How do I chose a different password variable for each loop of the script?  Oh, this is in a KeywordTest.

 

Or are there any other solutions?  Currently we're thinking about a Keepass db... 

4 Replies

  • cunderw's avatar
    cunderw
    Community Hero

    If you want to go the route of storing them as a password variable in test complete you could name all of the variables with a number at the end, use VariableByName and just append your counter to it.

     

    Project.Variables.VariableByName("password_" + counter)

    Alternatively, and I'm not sure if your test environment would allow this, but would it be possible to just set all of your test users to use the same password? That seems like better practice IMO, but the above solution should work also. 

    • AdamUK's avatar
      AdamUK
      Occasional Contributor

      Have figured it out, wouldn't have got there without you cunderw. 

       

      The solution is a more explicit version for anyone else interested:

       

      Project.Variables.VariableByName(aqString.Concat("ClientLoginName", KeywordTests.LoginAndPublishName.Variables.Counter3))

    • AdamUK's avatar
      AdamUK
      Occasional Contributor

      Thanks cunderw.  

       

      In theory that would work, in practice the 'counter' variable keeps throwing an error saying undefined (even though it is a local variable.  I'm trying various ways to get it to work. 

    • AdamUK's avatar
      AdamUK
      Occasional Contributor

      Unfortunately I can't set all the passwords to be the same as would be a security risk : )