document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. package visGrid;
  2.  
  3.  
  4. import java.net.MalformedURLException;
  5. import java.net.URL;
  6. import org.openqa.selenium.By;
  7. import org.openqa.selenium.WebDriver;
  8. import org.openqa.selenium.remote.DesiredCapabilities;
  9. import org.openqa.selenium.remote.RemoteWebDriver;
  10. import org.testng.annotations.AfterClass;
  11. import org.testng.annotations.BeforeClass;
  12. import org.testng.annotations.Parameters;
  13. import org.testng.annotations.Test;
  14.  
  15. public class Sample1 {
  16.  
  17.     public WebDriver driver;
  18.  
  19.     @Parameters({"browser"}) //this is to indicate that browser value is read from testng.xml file
  20.     @BeforeClass
  21.     public void beforeClass(String browser) throws MalformedURLException{
  22.         DesiredCapabilities capability= new DesiredCapabilities();
  23.         capability.setBrowserName(browser);
  24.         System.out.println(browser);
  25.         driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),capability);
  26.  
  27.     }
  28.  
  29.     @Test
  30.     public void search() throws Exception {
  31.         driver.get("http://www.bing.com");
  32.         driver.findElement(By.id("sb_form_q")).sendKeys("grid testing");
  33.        
  34.  
  35.     }
  36.     @AfterClass
  37.     public void afterClass(){
  38.         driver.quit();
  39.     }
  40.  
  41. }
');