Start a Project

How to apply condition for performing action on the basis of user logged in or not logged in check in Espresso.

In Espresso we create the test scripts for a particular scenario like “login to checkout” in which user will log in then the user will place order with his product.

But if the user already logged in, then our script will throw error at the beginning of the script.

So I have the solution for this, in which it will check whether the user already logged in or not , then it will perform action on the basis of logged in  state and not logged in state.

We will check that the user logged in or not on the basis of following :-

Now we will apply the condition of “if ” and “else” on the basis of that code:-

 

In the following code, we are checking that whether user logged in or not .

If the user is already logged in then “if” condition will be executed otherwise “else” condition will be executed by performing the action after logging in.

 

Hope this blog will help you.

 

 

Exit mobile version