How to use FireFoxDriver using Selenium 3.4.0 using Maven?

0 votes

I'm using Selenium's v3.4.0 in a maven project. I imported all Selenium's jars using the below dependency:-

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.4.0</version>
</dependency>

The issue is, I'm not able to resolve any dependency in my project in Eclipse for below code inside main method:-

public class FirefoxTest {

    public static void main(String[] args) {
        FirefoxOptions options = new FirefoxOptions();
        options.setBinary("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); //This is the location where you have installed Firefox on your machine

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

So, what could be wrong? Eclipse is unable to resolve FirefoxDriver type to any dependencies. Kindly help.

Apr 5, 2018 in Selenium by Martin
• 4,220 points
1,741 views

1 answer to this question.

0 votes

Your using the wrong functions to set the browser property. Use set.SystemProperty() and WebDriver() functions instead. Look at the below code to understand.

System.out.println("Welcome to Maven World");
System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();       
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
driver.navigate().to("http://www.google.com");

And also run the commands to flush out previous dependencies, to install the new dependencies & execute your test:

>mvn clean
>mvn install
>mvn test 

This should work.

answered Apr 5, 2018 by nsv999
• 5,110 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer
0 votes
0 answers
0 votes
2 answers

How to use Selenium with Python?

Hey Shubham, you can checkout this thread ...READ MORE

answered Aug 26 in Selenium by Abha
• 27,180 points
174 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,110 points
965 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
1,125 views
0 votes
1 answer
0 votes
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,110 points
2,288 views