Sunday, September 9, 2012

Selenium RC using Java Post 2 of 10

HTML Editor Sample Page

  

Run the Tests using TestNG Xml

You create a XML file and call the Test Suite to run using TestNG
Create a XML file --   New >>other >> XML >> XML file
In your xml file if you need to run the test suite you can  define it like this
<suite name="ABC_Testing" verbose="1" parallel="false" thread-count="1">
</suite>

If you want to provide a Test name which displays with your results then XML will look like this
<suite name="ABC_Testing" verbose="1" parallel="false" thread-count="1">
<test name="ABC Testing" thread-count="1">
</test>
</suite>

Now if you need to just run a one test class and methods allocated to that then your file should look like this
<suite name="ABC_Testing" verbose="1" parallel="false" thread-count="1">
<test name="ABC_Testing" thread-count="1">
<classes>
  <class name = "com.ABC.test.scripts.TestLogin">
   <methods>
            <include name="sucessLogin" />
         </methods>
  </class>
 </classes>
 </test>
</suite>
Now if you need to pass the data through your XML then you can parameterized your tests and then pass the data to your parameters using xml file
Now first you need to change your test to accept parameters.
@Test
                @Parameters({"userName","password"})
                public void testSucessLogin(String uname , String pword) {                    
        Sel.windowMaximize();
        Sel.open("http://ABC:8080/LogOn.aspx");
        Sel.type("id=body_UserNameTextBox",uname);
        Sel.type("id=body_PasswordTextBox", pword);
        Sel.click("id=body_LogOnButton");
        Sel.waitForPageToLoad("30000");cc
Now you need to define the parameters in the xml file and assign the values to them

<parameter name ="userName" value ="abc.admin@ABC.com"/>
<parameter name ="password" value ="Qwer1234"/>

Now the run the xml and see ………….



No comments:

Post a Comment