Selenium and testNG Integration

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

Selenium and testNG Integration

rkbernardo
Hello:

I started to use testNG a coupIe of days ago am attempting to integrate Selenium Web Driver and testNG.

I wrote a wrapper application to Selenium Web Driver and I am using testNG to invoke the methods of the wrapper application. But I am not sure how to run a method multiple times with different parameters from within the xml file.

The methods on the wrapper class are really generic for example: enterText(String elementName, String elementValue, boolean overWrite). So it can be reused and tests can easily created by editing the xml file.

Here is the xml file used by testNG which simulates a logging / logging out test to a website (Not sure how to call enterText twice with different parameters):

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Test Suite">
    <test name="Functional Testing">
        <classes>
            <class name="autotest.AutoTester" preserve-order="true">
                <methods>
                    <include name="startTest" />
                    <include name="navigateTo">
                        <parameter name="url" value="http://localhost"/>
                        <parameter name="pageLoadTimeout" value="pageLoadTimeout"/>
                    <include/>
                    <include name="enterText">
                        <parameter name="elementName" value="userName"/>
                        <parameter name="elementValue" value="admin"/>
                        <parameter name="overWrite" value="true"/>
                    <include/>
                    <include name="enterText">
                        <parameter name="elementName" value="password"/>
                        <parameter name="elementValue" value="password"/>
                        <parameter name="overWrite" value="true"/>
                    <include/>
                    <include name="clickLink">
                        <parameter name="linkName" value="Logout"/>
                    <include/>
                    <include name="submitForm"/>
                    <include name="finishTest" />
                </methods>
            </class>
        </classes>
    </test>
</suite>

Thanks

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/foSJ8Kd3DCUJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: Selenium and testNG Integration

Krishnan Mahadevan
Roderick,
If you wanted to iterate a test with different parameters the testng xml file is not the best option. You should look at using DataProviders instead. 

On Wednesday, October 31, 2012, Roderick wrote:
Hello:

I started to use testNG a coupIe of days ago am attempting to integrate Selenium Web Driver and testNG.

I wrote a wrapper application to Selenium Web Driver and I am using testNG to invoke the methods of the wrapper application. But I am not sure how to run a method multiple times with different parameters from within the xml file.

The methods on the wrapper class are really generic for example: enterText(String elementName, String elementValue, boolean overWrite). So it can be reused and tests can easily created by editing the xml file.

Here is the xml file used by testNG which simulates a logging / logging out test to a website (Not sure how to call enterText twice with different parameters):

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Test Suite">
    <test name="Functional Testing">
        <classes>
            <class name="autotest.AutoTester" preserve-order="true">
                <methods>
                    <include name="startTest" />
                    <include name="navigateTo">
                        <parameter name="url" value="http://localhost"/>
                        <parameter name="pageLoadTimeout" value="pageLoadTimeout"/>
                    <include/>
                    <include name="enterText">
                        <parameter name="elementName" value="userName"/>
                        <parameter name="elementValue" value="admin"/>
                        <parameter name="overWrite" value="true"/>
                    <include/>
                    <include name="enterText">
                        <parameter name="elementName" value="password"/>
                        <parameter name="elementValue" value="password"/>
                        <parameter name="overWrite" value="true"/>
                    <include/>
                    <include name="clickLink">
                        <parameter name="linkName" value="Logout"/>
                    <include/>
                    <include name="submitForm"/>
                    <include name="finishTest" />
                </methods>
            </class>
        </classes>
    </test>
</suite>

Thanks

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/foSJ8Kd3DCUJ.
To post to this group, send email to <a href="javascript:_e({}, &#39;cvml&#39;, &#39;testng-users@googlegroups.com&#39;);" target="_blank">testng-users@....
To unsubscribe from this group, send email to <a href="javascript:_e({}, &#39;cvml&#39;, &#39;testng-users%2Bunsubscribe@googlegroups.com&#39;);" target="_blank">testng-users+unsubscribe@....
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.


--
Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: Selenium and testNG Integration

rkbernardo
Hello Krishnan:
I have seen examples where different values are generated by the same data provider by looking into the method name.  But how can i load different parameters to from a data provider by to a method.

Thanks,
Roderick

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/9sufg1Wb5EoJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.

Reply | Threaded
Open this post in threaded view
|

Re: Selenium and testNG Integration

Krishnan Mahadevan
Ah! My bad. I read your question too soon perhaps. DataProvider is for different values for the same set of parameters. 

But coming to think of it, if there are different parameter invocations itself and on top of it if you are looking at iterations as well then I dont think if you could even use the suite file as well. 

Maybe you could come up with one parameter object that somehow captures all of this into it and can be instantiated by the data provider and passed on to the test method ?

On Thursday, November 1, 2012, Roderick wrote:
Hello Krishnan:
I have seen examples where different values are generated by the same data provider by looking into the method name.  But how can i load different parameters to from a data provider by to a method.

Thanks,
Roderick

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/9sufg1Wb5EoJ.
To post to this group, send email to <a href="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;testng-users@googlegroups.com&#39;)">testng-users@....
To unsubscribe from this group, send email to <a href="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;testng-users+unsubscribe@googlegroups.com&#39;)">testng-users+unsubscribe@....
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.



--
Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: Selenium and testNG Integration

rkbernardo
In reply to this post by rkbernardo
Hello Krishnan:

Thanks for your help, Is it possible to pass parameters to DataProviders other than the method name?

Thanks

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/N3v9wBGMUtQJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.