Login with multiple usernames

Class library usage, coding and language questions.
KiranZa
Posts: 4
Joined: Wed Feb 21, 2018 9:19 am

Login with multiple usernames

Post by KiranZa » Wed Feb 21, 2018 9:40 am

Hello,
I am very new to Ranorex and Test automization. I am currently using the Trail version to check if it works as we expect or not.
The problem i am facing might be very small. But I want to test the login to an application and use all the available usernames.
There are in total 9 username with the same password. So what I want to do is to try the first username/password combo, if its already in use then try the second one and so on...
If the first username is not currently in use then log in to the application and run further steps.
How should I proceed with this? Do I need to create a usercode? I am not good with programming but I can give it a try.

Kiran Zaheer

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Login with multiple usernames

Post by odklizec » Thu Feb 22, 2018 9:38 am

Hi,

Basic login of multiple users, is relative simple task and could be done via data-driven approach (described here).
However, your problem is somewhat more complicated and I think it may require some coding. The question is, how do you decide which user name is already taken? Could you please describe the whole process a bit more detailed? Also, we may need a Ranorex snapshot (NOT screenshot) of the login dialog. Because you are a new forum member, you will have to use a google drive or similar service, to post the snapshot here (as a link). Thanks.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

KiranZa
Posts: 4
Joined: Wed Feb 21, 2018 9:19 am

Re: Login with multiple usernames

Post by KiranZa » Mon Feb 26, 2018 9:48 am

Actually the application allows 9 users to login at a time. So there are username1....username9 with the same password. What I want to achieve is, at the time of running the test, the first user name is typed in and if its already in use by some other user... then the second and so on. The test shouldn't fail until it has tried all usernames and all of them are not available.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Login with multiple usernames

Post by odklizec » Mon Feb 26, 2018 10:01 am

Hi,

I understand the test flow, but I don't know how to tell a user is already logged in? This something you need to somehow validate, either via recording or code. Unfortunately, I'm unable to suggest something more specific without seeing the AUT or, at very least, a Ranorex snapshot of the login dialog/dialog determining a user is already logged in.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

KiranZa
Posts: 4
Joined: Wed Feb 21, 2018 9:19 am

Re: Login with multiple usernames

Post by KiranZa » Mon Feb 26, 2018 10:22 am

Yes, thats the only way. But I think I don't need to validate if the user is already logged in.
In case the username is available, there is no error dialog. So the testcase proceeds normally.
If the username is already in use, there is an error message. Is this possible to somehow decide to try next username based on this error dialog?
Also I have no idea where should my user code go? Should I create a method? or it should go to my LoginAUT.usercode.cs? and how to invoke this usercode?

Login Dialog:
https://drive.google.com/file/d/1DBhsst ... sp=sharing

Error Message: (Pardon, its in German)
https://drive.google.com/file/d/1XuSqSO ... sp=sharing

KiranZa
Posts: 4
Joined: Wed Feb 21, 2018 9:19 am

Re: Login with multiple usernames

Post by KiranZa » Tue Feb 27, 2018 11:23 am

Still looking for help!!

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Login with multiple usernames

Post by Support Team » Thu Mar 01, 2018 5:00 pm

Hi KiranZa,

To achieve your intention, you could create a structure like the one shown below
ConditionLoginTestSuite.png
ConditionLoginTestSuite.png (10.63 KiB) Viewed 423 times
The TestSuite itself contains a parameter called "loggedIn" which is set to false by default
ConditionLoginTestSuiteParameter.png
ConditionLoginTestSuiteParameter.png (7.36 KiB) Viewed 423 times
The TestCase has a condition that checks if the parameter "loggedIn" is false
ConditionLoginTestCaseCondition.png
ConditionLoginTestCaseCondition.png (11.52 KiB) Viewed 423 times
The modules "EnterCredentials" and "clickLogin" should be self-descriptive.

The CodeModule "isLoggedIn" basically checks if a user is alread logged in and sets the parameter "loggedIn" to true
ConditionLoginCodeModule.png
ConditionLoginCodeModule.png (14.73 KiB) Viewed 423 times
Once the parameter is set to true, the condition will be false and the Test Case is not executed anymore.

Of course, this sample is very basic and just checks the status strip for a logged in user, but it should give you an idea about the structure you can use for conditional execution.

Please let me know if you have any further questions.

Regards,
Markus (S)
.
Image