I am assuming that you want to create test case where you open the different webdriver related to different browser.
You need to start by creating a testNG class, here you will create test cases for different browsers. Then you will create a xml file where you will create the different class and test cases.
Here is a sample testNG class that I created that works for Chrome and Morzilla Firefox.
package testNG;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
public class MultipleTest
{
WebDriver driver;
String url = "https://www.google.com";
@Parameters("browserType")
@Test
public void invokebrowser(String browserType) throws InterruptedException
{
browserType = browserType.trim();
if (browserType.equalsIgnoreCase("chrome"))
{
System.setProperty("webdriver.chrome.driver","C:\\Users\\Downloads\\chromedriver.exe");
driver = new ChromeDriver();
}
else if(browserType.equalsIgnoreCase("firefox"))
{
System.setProperty("webdriver.gecko.driver", "C:\\Users\\Downloads\\geckodriver.exe");
driver = new FirefoxDriver();
}
else
{
System.out.println("Invalid Browser");
}
driver.manage().window().maximize();
driver.get(url);
Thread.sleep(2000);
driver.close();
}
}
Here is the XML file for the testNG class
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="ParellelTesting" parallel = 'tests'>
<test name = "Chrome Testing">
<parameter name = 'browserType' value = 'chrome'/>
<classes>
<class name = 'testNG.MultipleTest'/>
</classes>
</test>
<test name = "Firefox Testing">
<parameter name = 'browserType' value = 'firefox'/>
<classes>
<class name = 'testNG.MultipleTest'/>
</classes>
</test>
</suite>
Hope this will help.