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,210 points
1,136 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,030 points

Related Questions In Selenium

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

How to use Selenium with Python?

There are many resources for selenium - ...READ MORE

answered Mar 30, 2018 in Selenium by nsv999
• 5,030 points
117 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,030 points
51 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
410 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,030 points
1,195 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.