I just created feature file, step definition file and runner class file. Then I added project.properties under src/test/resources and given one property say below -
browser = InternetExplorer and using the same "browser" keyword in the background of feature file as shown below -
@RegisterUser
Feature: Register User on online shopping portal
Background:
Given I open browser
And I launch Online Shopping portal
When I click on Sign-In link
Then I am navigated to Sign-up page
@GoToSignUpPage
Scenario: User create an account
Given I am at sign-up page
When I enter the email id
And click create an account button
Then I am taken to create an account page
When I enter the personal and address details
And click Register button
Then I am taken to My Account page
now step definition has below codes -
public class genericsteps {
@Given("^I open (. *)$")
public void openBrowser(String browserName) {
System.out.println("Opening Browser "+browserName);
}
......... further all the step definition is given which I am showing as ..... here...
.........
.........
.........
}
then when I am running the runner class then I am getting below in the console o/p -
@RegisterUser
Feature: Register User on automation practice online shopping portal
Background: # src/test/resources/com/webautomation/feature/RegisterUsers.feature:22
Given I open browser # null
And I launch Online Shopping portal # genericsteps.launchsite()
When I click on Sign-In link # genericsteps.clicksigninlink()
Then I am navigated to Sign-up page # genericsteps.signuppage()
@RegisterUser @GoToSignUpPage
Scenario: User create an account # src/test/resources/com/webautomation/feature/RegisterUsers.feature:29
Given I am at sign-up page # genericsteps.registerpage()
When I enter the email id # genericsteps.enteremail()
And click create an account button # genericsteps.clickcreateanaccountbtn()
Then I am taken to create an account page # genericsteps.intocreateanaccountpage()
When I enter the personal and address details # genericsteps.enterdetails()
And click Register button # genericsteps.clickregisterbutton()
Then I am taken to My Account page # genericsteps.myaccountpage()
now if you check in above, Given I open browser # null.......why? it's getting undefined and how to resolve it....
Please suggest urgently....need help to submit small project in 4 days.....
Thank you.
Please find the screenshot of the code in the eclipse.
Please provide the solution asap.
Instructor
Ashish Thakur Replied on 15/07/2019
Did you try debugging the code?
As mentioned in Problem 1, this means that the object of properties file is not initialized.