Return Type of registerNewUser

classic Classic list List threaded Threaded
4 messages Options
J
Reply | Threaded
Open this post in threaded view
|

Return Type of registerNewUser

J
Hi Everyone ,

I had few questions which I am still not able to understand .

In the below code we are returning object of AccountCreationPage.However when I just do a enterFirstName(registrationData.getFirstName()) it gives me a error .So why do we need to send  a object which is so long(I got confused with so many registrationData getters returned in one single return statement  ).

Could you please explain it .

Thanks,
Jai

public AccountCreationPage registerNewUser(RegistrationData registrationData) {
       
        return enterFirstName(registrationData.getFirstName()).
                                enterLastName(registrationData.getLastName()).
                                enterPhone(registrationData.getPhoneNumber()).
                                enterUserName(registrationData.getUserName()).
                                selectCountry(registrationData.getCountry()).
                                enterEmail(registrationData.getEmail()).
                                enterPassword(registrationData.getPassword()).
                                enterConfirmPassword(registrationData.getConfirmPassword()).clickRegister(); */
Reply | Threaded
Open this post in threaded view
|

Re: Return Type of registerNewUser

softwaretestingforum
Administrator
You get the error because enterFirstName does not return AccountCreationPage object but if you see method signature for registerNewUser, it returns AccountCreationPage.
We could also write same method as -

public AccountCreationPage registerNewUser(RegistrationData registrationData) { 
        
        enterFirstName(registrationData.getFirstName()). 
                                enterLastName(registrationData.getLastName()). 
                                enterPhone(registrationData.getPhoneNumber()). 
                                enterUserName(registrationData.getUserName()). 
                                selectCountry(registrationData.getCountry()). 
                                enterEmail(registrationData.getEmail()). 
                                enterPassword(registrationData.getPassword()). 
                                enterConfirmPassword(registrationData.getConfirmPassword());
        
       return clickRegister(); 
}
~ seleniumtests.com
J
Reply | Threaded
Open this post in threaded view
|

Re: Return Type of registerNewUser

J
Thanks Tarun,

I was trying as below,where entering each items to test can be passed separately.Is this a correct approach ?.The reason I did that is because I was not able to understand how to we can pass everything in one line as enterFirstName(our test data).enterLastName(our test data)...


                        enterFirstName(registrationData.getFirstName());
                enterLastName(registrationData.getLastName());
                                enterPhone(registrationData.getPhoneNumber());
                                enterUserName(registrationData.getUserName());
                                selectCountry(registrationData.getCountry());
                                enterEmail(registrationData.getEmail());
                                enterPassword(registrationData.getPassword());
                                enterConfirmPassword(registrationData.getConfirmPassword());
                               
                                return clickRegister();
               
Reply | Threaded
Open this post in threaded view
|

Re: Return Type of registerNewUser

softwaretestingforum
Administrator
Let us see what does method - enterFirstName returns and what can be called on the returned object? Does it help?
~ seleniumtests.com