Unable to run the Regression group in testng.xml f

2020-05-07 06:55发布

问题:

I have configured the testng.xml file to run the Regression group in different browsers.Below is the testng.xml code for the same.

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="SeleniumSuite" verbose ="1" thread-count = "1" parallel="false">

 <**test** name="FirefoxTest">
  <groups>
        <run>
            <include name="Regression"></include>
        </run>
    </groups>
 <parameter name="browser" value="firefox" />
 <classes>
 <class name="Testscript.Program111_RediffLogin" />
 </classes>

 </test>
 <test name="IETest">
  <groups>
        <run>
            <include name="Regression"></include>
        </run>
    </groups>
 <parameter name="browser" value="ie" />
 <classes>
 <class name="Testscript.Program111_RediffLogin" />
 </classes>
 </test>
</suite>

when I hover the mouse on the tag, it displays an error message as "The content of element type "test" must match "(method-selectors?,parameter*,groups?,packages?,classes?)".At the Test class level I have defined all the parameters properly for the regression test to run.But still I am seeing the error in the testng.xml file.Can any one of you look into this and help me!

Please find the test case I am using for the automation

@Test(groups={"Regression"},dataProvider = "hashmapdataprovider",dataProviderClass =Dataprovider.Dataprovider_Hashmap.class,priority=1 )
public void validLogin(Map<String,String> hm) throws IOException
{
    pageobjects.Signin();
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);    
    OriginalExcelRW Excel = new OriginalExcelRW("F:\\anand_acer\\selenium\\rediffbooks.xlsx");
    XSSFSheet s1 = Excel.Setsheet("Sheet1");
    SoftAssert s_assert = new SoftAssert();
    if (hm.get("Executionflow").contains("anand"))
    {

    pageobjects.Username1(hm.get(Excel.Readvalue(s1, 0, 2)));
    pageobjects.pass1(hm.get(Excel.Readvalue(s1, 0, 3)));
    //s_assert.assertEquals(hm.get(Excel.Readvalue(s1, 0, 2)), hm.get(Excel.Readvalue(s1, 0, 3)), "both the usssser Ideee and password doesnt matches");
    //logger.info("Usssser Ideeee");
    pageobjects.login();
    s_assert.assertTrue(true, "login success");
    //logger.info("The login was success");
    System.out.println("Valid login is passed");
    pageobjects.signout();
    pageobjects.Signin();
    //pageobjects.cleartext();
    }
    s_assert.assertAll();
    }

回答1:

Looks like from the error message you have posted they must be in a special order of indentation?

Here is an example of my XML which works

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite verbose="1" name="example suite 1">
    <listeners>
         <listener class-name="ReportListener.ReportListenerClass" />
    </listeners>
    <test name="Logout tests">
        <classes>
            <class name="com.emc.qe.u360.tests.LogoutTests" />
        </classes>
    </test>
    <test name="Login tests">
        <classes>
            <class name="com.emc.qe.u360.tests.LoginPageTests" />
        </classes>
    </test> 
</suite>