why we assign firefoxdriver instance to webdriver

前端 未结 8 1628
时光说笑
时光说笑 2021-02-06 16:52

I am novice to Java or Selenium.

I just need help to understand one basic question.

Why we assign firefoxdriver instance to WebDriver? WebDriver driver=new Firef

8条回答
  •  温柔的废话
    2021-02-06 17:13

    package test.a1;
    
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.ie.InternetExplorerDriver;
    
    public class testDriver {
    
        public static void main(String[] args) 
        {
            // TODO Auto-generated method stub
            String browser="FireFox";
            if(browser=="Chrome")
            {
                System.setProperty("webdriver.chrome.driver",
                "C:\\Users\\LL\\chromedriver_win32\\chromedriver.exe");
    
                ChromeDriver driver = new ChromeDriver();
                driver.get("https://www.gmail.com");
            }
            else if(browser=="IE")
            {
    
                System.setProperty("webdriver.ie.driver","Drivers\\IEDriverServer.exe");
    
                InternetExplorerDriver driver = new InternetExplorerDriver();
                driver.get("https://www.gmail.com");
            }
            else if(browser=="FireFox")
            {
    
                FirefoxDriver driver = new FirefoxDriver();
                driver.get("https://www.gmail.com");
            }
        }
    }
    

    We can do this ..so kindly let know why ..we are doing this Webdriver driver=new FirefoxDriver();.

提交回复
热议问题