Firefox driver for selenium

随声附和 提交于 2019-12-22 12:26:16

问题


where to download the firefox driver for selenium?

I only find this, and herer is not the driver file for download https://code.google.com/p/selenium/wiki/FirefoxDriver

NOTE: I already have Selenium Webdriver IDE for Firefox but the script aks me to find firefox driver Can I use firefox in for webdriver in C# or its only capable for java?


回答1:


The best approach for C# projects is to install the WebDriver NuGet, because if there are any updates it will be notified. Just install NuGet Manager and search for WebDriver.

After that just use the following code:

IWebDriver driverOne = new FirefoxDriver();
IWebDriver driverTwo = new InternetExlorerDriver("C:\\PathToMyIeDriverBinaries\");

The FirefoxDriver is included in the NuGet. However, you need to download manually the ChromeDriver from here: https://code.google.com/p/selenium/wiki/ChromeDriver

You can find ten mins tutorial with images here: http://automatetheplanet.com/getting-started-webdriver-c-10-minutes/




回答2:


You just need to include/import driver to your project if you want to use firefox unlike for CHROME you need to store the jar file or Exe to a particular location and then then you just need to call it in your project

demo program

    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;

    public class Firefox {

         public void returnFirefoxBrowser(){
             WebDriver driver = new FirefoxDriver();
        }
    }

chrome

         File file = new File(
              "//Users//Documents//workspace//SELENIUM//chromedriver");
         System.setProperty("webdriver.chrome.driver",file.getAbsolutePath());
         WebDriver driver_chrome;
         driver_chrome = new ChromeDriver();


来源:https://stackoverflow.com/questions/31207067/firefox-driver-for-selenium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!