'Want to automate different login scenarios for different username and password combinations

I want to automate test scenarios for login functionality using different username and password combinations. FYI: Using pytest framework and selenium

What should I do to write that scenarios?

  1. Should I write only one testcase for all login combinations? OR
  2. Should I write different testcases for different login combination? (Recently, I have applied this method)

Scenarios which i have written:

  1. test_login_invalid_pass()
  2. test_login_empty_username()
  3. test_login_empty_pass()
  4. test_login_valid_pass()

Then, If I choose first method using parameterization then How to validate user login successfully or having error message of invalid credentials?

If I go for second method then I want to import username and password from excel file. Then How can i pass different login credentials to specific method



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source