Search code examples
javamavenselenium-webdriverfirefoxgeckodriver

Unable to import FirefoxOptions in Selenium Java


I am trying to import Firefox on my project, but it's not importing at all, even though I have downgraded selenium version as well. I am using following selenium maven dependency:

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

Whenever I am trying to import FireFoxOptions. It is showing red colour text, I need to know, if I am making any mistake.


Solution

  • The Selenium maven dependency is perfect.

    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.4.0</version>
    </dependency>
    

    This usecase

    Instead of importing FireFoxOptions you should have imported FirefoxOptions. A demonstration:

    • Code block:

      import org.openqa.selenium.WebDriver;
      import org.openqa.selenium.firefox.FirefoxDriver;
      import org.openqa.selenium.firefox.FirefoxOptions;
      
      public class genericTestFirefox {
      
        public static void main(String[] args) {
      
            FirefoxOptions options = new FirefoxOptions();
            options.setBinary("C:\\Program Files\\Mozilla Firefox\\firefox.exe");
            WebDriver driver = new FirefoxDriver();
            driver.get("https://www.google.com/");
        }
      }
      
    • Browser snapshot:

    Firefox