简体   繁体   中英

Unable to use Data Table Cucumber,

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| 
The first user shouldn 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!

Did you logout after your first test? In case that you are keeping your browser open, you will need to logout at the end, so you are back on the login page. Otherwise you might be redirected from the login page to homepage because there is a session active.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM