eclipseseleniumtestng-eclipse

What could be the best way to input various combination of username and password into browser in selenium?


I need to test a login form using selenium. The step checks by inputting various combination of the username and password. For eg. combination of username and password. I have used TestNG to perform the test. Is there any other approach that can be used or this is will be fine. Can POM be used for the purpose?


Solution

  • I suggest you to use Cucumber framework with Selenium so that you can define Scenario Outlines including different username and password variations. Here is an example:

    Scenario Outline: Sample Scenario: New user onboarding
    Given user navigates to blog page
    When user clicks "New"
    Then user should proceed "Onboarding" screen
    Then user enters "<SampleUserName>" to "Mail" area
    And user enters "<SamplePw>" to "Mail" area
    And user clicks "Submit"
    Examples:
      | SampleInValidMail              |  SamplePw  |
      | @example.com                   |  pw1       |
      | #@%^%#$@#$@#.com               |  pw2       |
      | \Joe Smith <email@example.com> |  pw3       |
      | email.example.com              |  pw4       |