user1700354
user1700354

Reputation: 107

How to set a driver path of firefoxdriver in selenium

Hi I am very new to selenium . So pardon me for any technical mistakes. I have a project which works fine for IE. But I need to test using firefox too. Does the project require a pointer towards the driver like IEDriver in case of execution in IE?

Upvotes: 5

Views: 61065

Answers (7)

BIpul Harsh
BIpul Harsh

Reputation: 11

Many of you might get the error in creating path to geckodriver or firefox-driver it's very easy just follow this way:

from selenium import webdriver
path = "home/sysname/Desktop/geckodriver"
driver = webdriver.Firefox(executable_path = path)

Notice that you have to write executable_path=path and then give path variable name.

Upvotes: 1

Sandeep Srivastav
Sandeep Srivastav

Reputation: 59

If we want to run the test case of Firefox then we need GeckoDriver. Use below link for downloading the latest geckodriver: https://github.com/mozilla/geckodriver/releases

Save the driver inside your project repository in a folder (you can give any name to the folder, i have used "BrowserDriver"). Use below code for calling the driver:

System.setProperty("webdriver.gecko.driver", System.getProperty("user.dir")+"/BrowserDriver/Mac/geckodriver 2");
WebDriver driver = new FirefoxDriver();

Upvotes: 2

kdoteu
kdoteu

Reputation: 1557

In my enviroment I set the property -Dwebdriver.firefox.bin="C:\Mozilla Firefox\firefox.exe"

Upvotes: 3

Subh
Subh

Reputation: 4424

You don't need to set the driver path for FirefoxDriver.
You can directly use WebDriver driver = new FirefoxDriver();.

However, there are other ways to run selenium in Firefox also, as below:

1- Using Firefox Profile;
Used to run selenium in a new user-defined profile with a set of preferences as necessary.

2- Using Firefox Binary;
[PS:- Not much Idea on how it works, But this link might help you out]

Upvotes: 6

Sanjay Kumar
Sanjay Kumar

Reputation: 379

import org.openqa.selenium.WebElement;//import this package
import org.openqa.selenium.By;        //import this package

WebDriver FF_river = new FirefoxDriver();//create a reference variable of FirefoxDriver() int

Upvotes: 0

Akash Thakare
Akash Thakare

Reputation: 22972

For testing with FireFox you can directly use driver = new FirefoxDriver() or you can download selenium driver for ie from this link and set path property as stated below.

System.setProperty("webdriver.ie.driver", "pathToTheIEDriver");
WebDriver driver = new InternetExplorerDriver();

Upvotes: 1

grasshopper
grasshopper

Reputation: 4068

You just need to create a WebDriver that is an instance of Firefox, like so:

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;


WebDriver driver = new FirefoxDriver();

Upvotes: 0

Related Questions