How to set a variable for test-case-condition

Best practices, code snippets for common functionality, examples, and guidelines.
User avatar
Mudhenn
Posts: 20
Joined: Fri Apr 22, 2016 12:28 pm
Location: Vienna, Austria

How to set a variable for test-case-condition

Post by Mudhenn » Fri Sep 22, 2017 5:13 pm

Hello
I need to check if the user is already signed in or not and then do the login-part or not. I can do this by checking fore some words on the screen.
So my plan is to have a variable which acts as an condition for the login-part (or that smart-folder what they are called nowadays).
Sadly I'm not able to get something like that working, I am not an programmer to find help in the "manual" thats provided or in the topics here in the forum.
(If you can show me, what to read, I will do so of course)

So just this:
1. Check if one repo-item exists (maybe validate.exists?)
2. Set the/one variable/parameter/global thing to one value or the other.
3. Insert the condition in the testcase.

I can check part 1. with sometling like validate.exists, which I found in the code examples, but I cant figure out what to do with it besides from looking at its success or not in the report. Everytime I try something I get errors with voids, bools and strings and why they can't be converted and I'm lost.
I also know how to check part 3 if I only knew how to get the results from 1 into the variable for 3...

If anybody can point me in the right direction that would be great.

TIA,
Frank

User avatar
N612
Posts: 135
Joined: Mon Jul 11, 2016 4:01 pm

Re: How to set a variable for test-case-condition

Post by N612 » Fri Sep 22, 2017 9:22 pm

This can be achieved without going into code. Below is one of the many ways you can do this. Note, the module and variable names can be changed to anything you would like.

1. Create a global parameter "UserNameText"
2. Bind it to CheckIfLoggedIn recording modules variable "varUserNameText"
3. In CheckIfLoggedIn recording module, use a Get-Value to set the "varUserNameText" with the attribute you are using to check if the user is logged in
  • 1checkifloggedin.png
4. Create two child-test cases, "Logged In" and "Not_LoggedIn"
  • 1ts.png
5. Adjust the conditional statements accordingly for the global parameters
  • 1loggedin.png
You do not have the required permissions to view the files attached to this post.