Firefox WebDriver Test with Selenium Java API


How to create a test program using Firefox WebDriver with Selenium Java API?



Here is a simple test program that the Firefox WebDriver Test with the Selenium Java API:

C:\fyicenter> type

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.*;
public class FirefoxTest {
  public static void main(String[] args) {
     WebDriver driver = new FirefoxDriver();

Compile and run it with the Selenium Client JAR file:

C:\fyicenter> javac -classpath \
   \fyicenter\selenium\java\client-combined-3.141.59.jar \

C:\fyicenter> java -classpath \
   \fyicenter\selenium\java\libs\commons-exec-1.3.jar \

Exception in thread "main" java.lang.IllegalStateException: 
   The path to the driver executable must be set by the webdriver.gecko.driver system property; 
   for more information, see 
   The latest version can be downloaded from
   at org.openqa.selenium.remote.service.DriverService.findExecutable(
   at org.openqa.selenium.firefox.GeckoDriverService.access$100(
   at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(
   at org.openqa.selenium.remote.service.DriverService$
   at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(

As you can see, we are missing the Mozilla GechoDriver. See next tutorial on how to fix it.


Use Firefox WebDriver with Mozilla GechoDriver

Compatibility of WebDriver Java API for Chrome

Starting with Selenium WebDriver Client Java API

⇑⇑ Selenium Tutorials

2020-01-29, 207👍, 0💬