2

im asking if is there any way to combine outline scenario and data tables like the example bellow:

Feature: User Sign UP

  Scenario Outline: User <User> tries to signup with improper combination of password
    Given the user <User> has browsed to the signup page
    When the user <User> tries to signup entering the following details
      | email           | <Email>            |
      | password        | <Password>         |
      | confirmPassword | <ConfirmPassword>  |
    Then an error message <validation> should be shown above the password field
    Examples:
      | User    | Email                   |Password          | ConfirmPassword  | validation                         |
      | user1   | email1@gmail.com        | 234567569        | 234567569        | This password is entirely numeric. |
      | user2   | email2@gmail.com        | 123456789        | 123456789        | This password is too common.       |

Java Step Class:

   @When("the user (.+) tries to signup entering the following details")
    public void testAdd2(String user,DataTable dataTable) throws Throwable {
    //Asserts
    }

Thank's for your time.

AHmedRef
  • 2,555
  • 12
  • 43
  • 75

1 Answers1

2

It is possible but maybe it is easier to not to use data table:

Scenario Outline: User <User> tries to signup with improper combination of password
    Given the user <User> has browsed to the signup page
    When the user <User> tries to signup entering <Email> <Password> and <Confirm Password>
    Then an error message <validation> should be shown above the password field
    Examples:
      | User    | Email                   |Password          | ConfirmPassword  | validation                         |
      | user1   | email1@gmail.com        | 234567569        | 234567569        | This password is entirely numeric. |
      | user2   | email2@gmail.com        | 123456789        | 123456789        | This password is too common.       |

And java step

@When("the user (.+) tries to signup entering the following (.+) (.+) and (.+)")
    public void testAdd2(String user,String email,String password,String confirmPassword,) throws Throwable {
    //Asserts
    }

But if you want to use data table you need to convert it to list like in example code below:

public void readDataTableElements(DataTable dt) {
    List<String> list = dt.asList(String.class);
    System.out.println("First element - " + list.get(0));
    System.out.println("Next element - " + list.get(1));
WKOW
  • 346
  • 2
  • 9
  • Please give me a feedback if my answer was helpful. – WKOW Dec 01 '20 at 10:37
  • 1
    my code work fine, i hjad just some misconfiguration in my projet, your code work also fine, but in this case using datatables is more flexible. – AHmedRef Dec 01 '20 at 22:02