running selenium webdriver test cases against multiple browsers

后端 未结 3 1581
野性不改
野性不改 2021-02-02 03:03

I am new to selenium testing. I want to run selenium test cases on multiple browsers against internet explorer, Firefox, opera and chrome. What approach i have to f

3条回答
  •  日久生厌
    2021-02-02 03:46

    import org.junit.Test;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.ie.InternetExplorerDriver;
    
    public class Sample {
        private WebDriver _driver;
    
        @Test
        public void IEconfiguration() throws Exception {
            System.setProperty("webdriver.ie.driver",
            "D:/Softwares/Selenium softwares/drivers/IEDriverServer.exe");
            _driver = new InternetExplorerDriver();
            login();
        }
    
        @Test
        public void FFconfiguration() throws Exception {
            _driver = new FirefoxDriver();
            login();
        }
    
        @Test
        public void CRconfiguration() throws Exception {
            System.setProperty("webdriver.chrome.driver",
                    "D:/Softwares/Selenium softwares/drivers/chromedriver.exe");
            _driver = new ChromeDriver();
            //_driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
            login();
        }
    
        public void login() throws Exception {
            _driver.get("http://www.google.com");
        }       
    }
    

    Before that we have to install the chrome and internet explorer drivers .exe files and run those.

提交回复
热议问题