I`m using Cucumber Selenium and Data Table for my Login Scenario. Here is my scenario:
Scenario Outline: User login
Given the user is on Login Page
And the users enter "<username>" and "<password>"
Examples:
| username| password|
| User_1 | passw123|
| User_2 | passw123|
t log out because I
m testing limit of logged users.
For example:
1. The first user log in and stay in an app
Expected result: User successfully login
2. The second user tries to log in
Expected result: User can`t log in because of limit
But when using the second credentials, the Login page not open, the page just refreshed and displayed Homepage of the first logged user ( User_1, passw123). And I have Assertion Error:
Caused by: java.lang.AssertionError: (after 5000 ms)
Expected: "Login Page"
but: was "Home Page"
How can it be handled? Thank you!
You definitely should not use scenario outline for such purposes.
What you can do is:
Create one test and describe it like:
Open login page with new browser
And the users enter "User1" and "password1"
Open login page with new browser
And the users enter "User2" and "password2"
Inside step Open login page with new browser
you should create new Instance of webdriver and set it as a main driver for all others steps.
But from my opinion use Selenium for testing such auth logic it is wrong idea, because you do not test any UI behavior, all you test is server side logic. So it would be convenient to use Rest-assured and test that logic via http requests.