0

Is it possible to specify multiple browser as parameter for cross-browser testing in TestNG without repeating the test itself? As in:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Cross-browser suite" verbose="1">
    <test name="Cross-browser test">
        <parameter name="browsers" value="chrome,msedge,firefox" />
        <classes>
            <class name="TestClass" />
        </classes>
    </test>
</suite>

Of course I could always handle the browsers parameter to instantiate multiple WebDrivers, but doing so would make test execution times not be reliable anymore, as what would be repeated would be the actual test code instead of the test itself. This might prove be extremely useful when working with very large testng.xml files. Is there any way I can achieve this?

EDIT:

Unfortunately I can't use @DataProvider as I'm using the browsers parameter inside a @BeforeMethod method (that is, where I'm instantiating the WebDriver). Also, I'm already using DataProviders all across my test codebase to get test parameters from an .xlsx file.

lucacelenza
  • 1,259
  • 1
  • 15
  • 28

0 Answers0