An implementation of the {#link WebDriver} interface that drives Firefox. The best way to construct a FirefoxDriver with various options is to make use of the FirefoxOptions, like so: FirefoxOptions options = new FirefoxOptions() .addPreference("browser.startup.page",
| 58 | * </pre> |
| 59 | */ |
| 60 | public class FirefoxDriver extends RemoteWebDriver |
| 61 | implements HasExtensions, HasFullPageScreenshot, HasContext, HasBiDi { |
| 62 | |
| 63 | private static final Logger LOG = Logger.getLogger(FirefoxDriver.class.getName()); |
| 64 | private final Capabilities capabilities; |
| 65 | private final HasExtensions extensions; |
| 66 | private final HasFullPageScreenshot fullPageScreenshot; |
| 67 | private final HasContext context; |
| 68 | |
| 69 | /** |
| 70 | * Creates a new FirefoxDriver using the {@link GeckoDriverService#createDefaultService)} server |
| 71 | * configuration. |
| 72 | * |
| 73 | * @see #FirefoxDriver(FirefoxDriverService, FirefoxOptions) |
| 74 | */ |
| 75 | public FirefoxDriver() { |
| 76 | this(new FirefoxOptions()); |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Creates a new FirefoxDriver instance with the specified options. |
| 81 | * |
| 82 | * @param options The options to use. |
| 83 | * @see #FirefoxDriver(FirefoxDriverService, FirefoxOptions) |
| 84 | */ |
| 85 | public FirefoxDriver(FirefoxOptions options) { |
| 86 | this(options, ClientConfig.defaultConfig()); |
| 87 | } |
| 88 | |
| 89 | public FirefoxDriver(FirefoxOptions options, ClientConfig clientConfig) { |
| 90 | this(GeckoDriverService.createDefaultService(), options, clientConfig); |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Creates a new FirefoxDriver instance. The {@code service} will be started along with the |
| 95 | * driver, and shutdown upon calling {@link #quit()}. |
| 96 | * |
| 97 | * @param service The service to use. |
| 98 | * @see RemoteWebDriver#RemoteWebDriver(org.openqa.selenium.remote.CommandExecutor, Capabilities) |
| 99 | */ |
| 100 | public FirefoxDriver(FirefoxDriverService service) { |
| 101 | this(service, new FirefoxOptions()); |
| 102 | } |
| 103 | |
| 104 | public FirefoxDriver(FirefoxDriverService service, FirefoxOptions options) { |
| 105 | this(service, options, ClientConfig.defaultConfig()); |
| 106 | } |
| 107 | |
| 108 | public FirefoxDriver( |
| 109 | FirefoxDriverService service, FirefoxOptions options, ClientConfig clientConfig) { |
| 110 | this(generateExecutor(service, options, clientConfig), options, clientConfig); |
| 111 | } |
| 112 | |
| 113 | private static FirefoxDriverCommandExecutor generateExecutor( |
| 114 | FirefoxDriverService service, FirefoxOptions options, ClientConfig clientConfig) { |
| 115 | Require.nonNull("Driver service", service); |
| 116 | Require.nonNull("Driver options", options); |
| 117 | Require.nonNull("Driver clientConfig", clientConfig); |