Tuesday, 4 August 2015

How to run script on firefox, chrome and IE parallaly on Selenium Webdriver using java?.


import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

public class FirefoxchromeIEbrowser {

    static WebDriver fireFoxDriver = null;
    static WebDriver chromeDriver = null;
    static WebDriver internetExplorerDriver = null;

    public static void main(String[] arg) {
        //create firefox instance
        fireFoxDriver = new FirefoxDriver();
        //Maximize browser window    
        fireFoxDriver.manage().window().maximize();
        //Go to URL
        fireFoxDriver.get("http://www.yahoo.com");    
        //close FireFox browser 
        fireFoxDriver.quit();

        //set chrome driver path
        System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "\\chromedriver.exe");
        //create chrome instance
        chromeDriver = new ChromeDriver();
        //Maximize browser window    
        chromeDriver.manage().window().maximize();
        //Go to URL
        chromeDriver.get("http://www.gmail.com");
        //close Chome browser 
        chromeDriver.quit();

       
        ////set IE driver path
        System.setProperty("webdriver.ie.driver", System.getProperty("user.dir") + "\\IEDriverServer.exe");
        System.out.println(System.getProperty("user.dir") + "\\IEDriverServer.exe");
        //create IE instance
        internetExplorerDriver = new InternetExplorerDriver();
        //Maximize browser window 
        internetExplorerDriver.manage().window().maximize();
        //Go to URL
        internetExplorerDriver.get("http://www.google.com/");
        //close IE browser
        internetExplorerDriver.quit();
    }

}


No comments:

Post a Comment