Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
881 views
in Technique[技术] by (71.8m points)

selenium - Why do we need to set the System Property for Chrome And IE Browser and Not For Firefox Browser

For Chrome,

public class Chrome {

  public static void main(String[] args) {

        System.setProperty("webdriver.chrome.driver", "E://chromedriver.exe");
        WebDriver driver = new ChromeDriver();              
        driver.get("http://www.google.com");

    }

}

for Firefox,

public class Firefox {

      public static void main(String[] args) {

            WebDriver driver = new FirefoxDriver();              
            driver.get("http://www.google.com");

        }

    }

Why do we need to specify the system.setProperty for Chrome and IE?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I had also same question, but after digging I found,

WebDriver uses native browser approach. Selenium offers inbuilt driver for Firefox but not for other browsers. All drivers (Chrome Driver, IE driver, etc.) are built based on the special JS Engine used by each browser.

Selenium WebDriver works very well with Mozilla Firefox because it has a built in driver server. But the same is not true for Internet Explorer and Google Chrome. Firefox is the most traditional browser, thus Selenium WebDriver do not require any additional utility to be set before launching the browser. The Selenium package automatically references towards the default location of the firefox.exe, thus the user need not to set any other property.

If you ever get the “the path to the driver executable must be set by the webdriver. ie. driver system property” error or its similarly worded Chrome equivalent, it means that you need to install the driver servers on your browser. The driver server manages the calls between the browsers and the Selenium wire protocol.

The InternetExplorerDriver is a standalone server which implements WebDriver’s wire protocol

Similarly, Google Chrome doesn’t have a built-in server so you will need a Chrome driver server for communicating your Selenium code to the browser. You can download the Chrome driver server.

Founded from here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...