document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. package parallel;
  2.  
  3. import org.openqa.selenium.By;
  4. import org.openqa.selenium.WebDriver;
  5. import org.openqa.selenium.chrome.ChromeDriver;
  6. import org.openqa.selenium.firefox.FirefoxDriver;
  7. import org.openqa.selenium.ie.InternetExplorerDriver;
  8. import org.testng.annotations.AfterClass;
  9. import org.testng.annotations.BeforeClass;
  10. import org.testng.annotations.Parameters;
  11. import org.testng.annotations.Test;
  12.  
  13. public class CrossBrowserTest {
  14.  
  15.     private WebDriver driver;
  16.  
  17.     // Configuration for cross browser
  18.     @Parameters("browser")
  19.     @BeforeClass
  20.     public void beforeTest(String browser) {
  21.         if (browser.equalsIgnoreCase("firefox")) {
  22.             driver = new FirefoxDriver();
  23.         }
  24.         else if (browser.equalsIgnoreCase("chrome")) {
  25.             // Set Path for the executable file
  26.             System.setProperty("webdriver.chrome.driver","F:\\\\Jar\\\\chromedriver.exe");
  27.             driver = new ChromeDriver();
  28.         }
  29.         else if (browser.equalsIgnoreCase("ie")) {
  30.             // Set Path for the executable file
  31.             System.setProperty("webdriver.ie.driver", "F:\\\\Jar\\\\IEDriverServer.exe");
  32.             driver = new InternetExplorerDriver();
  33.         }
  34.         else {
  35.             throw new IllegalArgumentException("The Browser Type is Undefined");
  36.         }
  37.  
  38.     }
  39.  
  40.     @Test
  41.     public void multiBrowser() throws Exception {
  42.         //Open URL
  43.         driver.get("http://bing.com");
  44.         //Search for testerinyou blog
  45.         driver.findElement(By.id("sb_form_q")).sendKeys("testerinyou.blogspot.in");
  46.         //click search button
  47.         driver.findElement(By.id("sb_form_go")).click();
  48.         //in results page click the link
  49.         driver.findElement(By.partialLinkText("Selenium IDE, Selenium RC and Webdriver")).click();
  50.         Thread.sleep(5000);
  51.     }
  52.  
  53.     @AfterClass
  54.     public void afterTest() {
  55.         driver.quit();
  56.     }
  57. }
');