Mavenizing the selenium

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

Mavenizing the selenium

tarunohri
Hello

My question in related to the selenium video tutorial(mavenizing selenium).
If we have to get the data from RegistrationData class to WebDriverTest class using annotations (dataProvider = "regData") , then why did we used the property file ??

In other words,
(*)The constructor of the RegistrationData class is doing the same job as its method "getRegistrationData", Though both are providing the data in different ways !!
(*) Providing the data using "regData" is ok, But what if we have to provide the data using the constructor of the RegistrationData class?? Can we annotate the constructor the same way we do to the methods to provide the data ??

Thanks !!!
Reply | Threaded
Open this post in threaded view
|

Re: Mavenizing the selenium

softwaretestingforum
Administrator
The advantage of using test data provider method is that it can be used to pass on different data set for same test method. This can not be achieved using constructor of class.
Properties files are to externalize data, that is to not hard code data with in test classes.

Does it answer your question?
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Mavenizing the selenium

tarunohri
Thanks for replying . What you said is very right but i wanted to know that why are we using two ways to assign data to the same bean ( property & dataprovider )
<code>
@Test(dataProvider = "regData", dataProviderClass = RegistrationData.class)
        public void newRegistration(RegistrationData registrationData) {
                driver.get(appURL);
                NewRegistrationPage registration = PageFactory.initElements(driver,
                                NewRegistrationPage.class);
                registration.registerNewUser(registrationData);
                assert driver......................
<code>

Q1. In the above method (ie. newRegistration)the data is coming from the dataprovider( ie regdata method) .. But this method (ie. newRegistration) is taking class type object of the RegistrationData class as its parameters . So when the pass an object of the RegistrationData in the newRegistration method ... the constructor of the RegistrationData would be called... right ? And the constructor contains the data set from the properties file .
In short,
public void newRegistration(RegistrationData registrationData)
this method is getting the data from two ways simultaneously ie:
1. From constructor invocation
2. From dataprovider method
How we will figure out which mode of data we are using for test ??
I hope i am able to put my question clearly this time.
Reply | Threaded
Open this post in threaded view
|

Re: Mavenizing the selenium

softwaretestingforum
Administrator
nop, the data is being sent only from data provider methods.
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Mavenizing the selenium

tarunohri
Thanks i got it, Actually u have provided the provision to get data through  properties, required a bit of edit to implement it
My bad, i misunderstood it in first place .