I need to automate a registration form and create a new account and then use the same account details to login with newly created account number and password.I need to do this in one scenario.
Feature: create new user and capture the username, password and try to login with those details.
Scenario: test
Given I am on xyz.com
When I click on register
Then I will enter required details for registration
Then I will click on submit
And I will enter new account details to login to test.
I would not do that in one scenario unless it is one flow. And I wouldn't go to xyz.com, and I wouldn't click on things because that isn't 'behavior. Page objects will help you.
Scenario: Register a new account
Given I do not have an account
When I register a new account
Then I can use those credentials to access the site
Then I'd create appropriate steps
Given(/^I do not have an account%/) do
@credentials = get_unique_credentials
@browser = Watir::Browser.new :firefox
end
When(/^I register a new account$/) do
visit RegistrationPage do |page|
page.name = @credentials[0]
page.password = @credentials[1]
page.register
end
end
Then(/^I can use those credentials to access the site$/) do
visit LoginPage do |page|
page.name = @credentials[0]
page.password = @credentials[1]
page.login
end
on HomePage do |page|
expect(page.something).to exist
end
end