title: Selenium testing on different browsers using TestNG
body: <p>So currently I am doing something like this to do cross browser testing:</p>
  
  <pre><code>@DataProvider(name="foo")
  public Object[][] getDrivers() {
      DesiredCapabilities firefoxCapabs = DesiredCapabilities.firefox();
      capabillities.setCapability("version", "26");
      capabillities.setCapability("platform", Platform.WINDOWS);
      DesiredCapabilities chromeCapabs = ....
      ....
      DesiredCapabilities ieCapabs = ...
      ....
  
      return new Object[][]{
          {new RemoteWebDriver(url, firefoxCapabs)}, 
          {new RemoteWebDriver(url, chromeCapabs)},
          ......
      };
  }
  
  @Test(dataProvider="foo")
  public void testSomething(WebDriver driver) {
      //some test
  }
  </code></pre>
  
  <p>This seems extremely inefficient as I am basically creating and destroying these WebDriver objects every time I run a test. Is there no way to do something like this at least at the TestSuite level so that I am not generating and destroying these objects for every test. I would like something like below. I am aware that you cannot have a DataProvider for @BeforeSuite methods!</p>
  
  <pre><code>public class TestSuite{
      public static WebDriver driver;
      @BeforeSuite(dataProvider="foo")
      public void setDriver(WebDriver driver) {
           this.driver = driver;
      }
  }
  
  public class TestClass {
      private WebDriver driver;
  
      @BeforeTest
      public void getDriver() {
          this.driver = TestSuite.driver;
      }    
  
      @Test
      public void myTest() {
          //use this.driver to do testing stuff
      }
  }
  </code></pre>
  
  <p>Are there options I am not seeing to do something like this?</p>