Код: Выделить всё
Scenario: As someone who wants to sign up
When I visit the homepage
And I click on the Register button
And I enter my firstname
And I enter my surname
And I enter my email address
And I enter a new password
And I re-enter my new password
And I agree to the terms and conditions
And I click the Submit button
Then I should see a welcome page
< /code>
Я понимаю, что шаг, генерируемые огурцом, генерирует отдельный метод для каждого из них, что нормально. Придется ли я тогда реализовать каждый из этих шагов в «Регистрации» в своем собственном методе? То, что я пытаюсь получить, это: есть ли способ реализовать своего рода метод "filinform ()" вместо отдельных методов в регистрации? Моя цель - иметь возможность сделать что -то вроде этого: < /p>
Scenario Outline: As someone who wants to sign up
When I visit the homepage
And I click on the Register button
And I enter my "" in the firstname input
And I enter my "" in the surname input
And I enter my "" in the email input
And I enter my "
" in the password input
And I enter my "" in the password confirmation input
And I agree to the terms and conditions
And I click the Submit button
Then I expect the registration to ""
Examples:
| firstname | surname | emailaddress | password | ExpectedResult |
| First | User | first@somewhere.com | | Fail |
| Second | User | second@somewhere.com | . | Fail |
| Third | User | third@somewhere.com | toofew | Fail |
| Fourth | User | fourth@somewhere.com | weakpassword | Fail |
| Fifth | User | fifth@somewhere.com | MissingNumber | Fail |
| Sixth | User | sixth@somewhere.com | m1ssingc4pital | Fail |
| seventh | User | seventh@somewhere.com | CapsAndNumb3r | Pass |
< /code>
Учитывая такой контур сценария, будет ли все еще возможно заполнить регистрационную форму, используя один метод? Что -то, о чем я думал (и я не уверен, каковы это было бы последствия): < /p>
@When("^I enter \"([^\"]*)\" in the firstname input$")
public void enterFirstname(String firstname) {
registrationPage.firstname = firstname;
}
< /code>
, а затем, когда тест нажимает кнопку «Отправить»: < /p>
@When("^I click the Submit button$")
public void clickSubmitButton() {
registrationPage.fillInForm();
registrationPage.clickJoinButton();
}
Подробнее здесь: https://stackoverflow.com/questions/482 ... n-web-form