Running Selenium Code on Multiple Browsers

Below is the code which might be helpful to you. This code will allow you to launch your URL in Google Chrome, Internet Explorer as well as in Firefox:

public class browsers {
public static WebDriver driver = null;
public static void openbrowser (String browser)
{
if (browser.equalsIgnoreCase("Firefox"))
{
System.out.println("initiated");
driver = new FirefoxDriver();
}

else if (browser.equalsIgnoreCase("InternetExplorer"))
{
DesiredCapabilities ie = DesiredCapabilities.internetExplorer();
ie.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
System.setProperty("webdriver.ie.driver", "C://Users//DELL//Desktop//Raghav//selenium//Resource//IEDriverServer.exe");
driver = new InternetExplorerDriver(ie);

}
else if (browser.equalsIgnoreCase("Chrome"))
{
System.setProperty("webdriver.chrome.driver", "C://Users//DELL//Desktop//Raghav//selenium//Resource//chromedriver.exe");
driver = new ChromeDriver();
}
}