i am using selenium with java , cucumber , j unit and Gradle.
on my registration form there are many fields which has the validation message.
For example username field gives below error messages 1) When use the existing username giving "Username already exists " 2) Empty username giving " required " validation message 3) Its only allowing to create username which contains a-z and 0-9 if not then giving "can only contain a-z and 0-9" message
Do i need to create the separate tests to check this validation message? Like below
Feature file :
@usernamevalidation
Scenario Outline: Username already exist
When Click on SignUp
And username is '<username>'
And phone is '<phonenumber>'
And Email is '<email>'
And companyname is '<companyname>'
Then validation of username and email
Examples: :
| username | phonenumber | email | companyname |
| romalwinn888554 | 65236523 | phurbadolma@yahoo.com | AAA |
| laroche | 789654456 | phurbadolma@yahoo.com | AAA |
| macharya1 | 786541212 | phurbadolma@yahoo.com | AAA|
Method :
public void userAlreadyExist(){
utils.waitForElements(useralreadyExist , KnowsTestContext.timeout , KnowsTestContext.driver);
String actual = useralreadyExist.getText();
String expected = "Username already exists" ;
Assert.assertEquals(actual , expected);
}
public void emailAlreadyExist(){
utils.waitForElements(emailalreadyExist , KnowsTestContext.timeout , KnowsTestContext.driver);
String actual = emailalreadyExist.getText();
String expected = "Email already exists" ;
Assert.assertEquals(actual , expected);
}
Is it possible to do all the validation in one method ?