Re: [testng-users] Selenium and testNG Integration

75 views
Skip to first unread message

Krishnan Mahadevan

unread,
Oct 31, 2012, 9:58:38 PM10/31/12
to testng...@googlegroups.com
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 testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
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/

Roderick

unread,
Oct 31, 2012, 10:43:35 PM10/31/12
to testng...@googlegroups.com
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

Krishnan Mahadevan

unread,
Oct 31, 2012, 10:56:56 PM10/31/12
to testng...@googlegroups.com
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 ?
--
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 testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.

Roderick

unread,
Nov 1, 2012, 9:27:54 AM11/1/12
to testng...@googlegroups.com
Hello Krishnan:

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

Thanks
Reply all
Reply to author
Forward
0 new messages