How to Launch Multiple Browser in Webdriver
Launch Multiple Browser Example:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.safari.SafariDriver;
public class MutlipleBrowserExample {
public static void main(String[] args) {
String browserType="FireFox";
WebDriver driver=null;
if(browserType.equals("FireFox"))
{
driver=new FirefoxDriver();
}
else if (browserType.equals("Chrome")) {
System.setProperty("webdriver.chrome.driver","E:\\SOFTWARES\\chromedriver.
exe");// path of chrome server for Webdriver
WebDriver d=new ChromeDriver();
}
else if (browserType.equals("IE")) {
WebDriver driver = new InternetExplorerDriver();
capabilities.setBrowserName("safari");
CommandExecutor executor = new SeleneseCommandExecutor(new
URL("http://localhost:4444/"), new URL("http://www.google.com/"), capabilities);
WebDriver driver = new RemoteWebDriver(executor, capabilities);
}
}
}
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.safari.SafariDriver;
public class MutlipleBrowserExample {
public static void main(String[] args) {
String browserType="FireFox";
WebDriver driver=null;
if(browserType.equals("FireFox"))
{
driver=new FirefoxDriver();
}
else if (browserType.equals("Chrome")) {
System.setProperty("webdriver.chrome.driver","E:\\SOFTWARES\\chromedriver.
exe");// path of chrome server for Webdriver
WebDriver d=new ChromeDriver();
}
else if (browserType.equals("IE")) {
System.setProperty("webdriver.ie.driver","C:\\Users\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
capabilities.setBrowserName("safari");
CommandExecutor executor = new SeleneseCommandExecutor(new
URL("http://localhost:4444/"), new URL("http://www.google.com/"), capabilities);
WebDriver driver = new RemoteWebDriver(executor, capabilities);
}
DesiredCapabilities capabilities = new DesiredCapabilities();
}
}
}
0 comments:
Post a Comment