Package org.openqa.selenium.firefox
Class FirefoxDriver
java.lang.Object
org.openqa.selenium.remote.RemoteWebDriver
org.openqa.selenium.firefox.FirefoxDriver
- All Implemented Interfaces:
HasBiDi,HasFederatedCredentialManagement,HasContext,HasExtensions,HasFullPageScreenshot,HasCapabilities,HasDownloads,WebStorage,Interactive,JavascriptExecutor,PrintsPage,SearchContext,TakesScreenshot,HasVirtualAuthenticator,WebDriver
public class FirefoxDriver
extends RemoteWebDriver
implements WebStorage, HasExtensions, HasFullPageScreenshot, HasContext, HasBiDi
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", 1)
.addPreference("browser.startup.homepage", "https://www.google.co.uk")
.setAcceptInsecureCerts(true)
.setHeadless(true);
WebDriver driver = new FirefoxDriver(options);
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.openqa.selenium.remote.RemoteWebDriver
RemoteWebDriver.RemoteTargetLocator, RemoteWebDriver.RemoteWebDriverOptions, RemoteWebDriver.WhenNested classes/interfaces inherited from interface org.openqa.selenium.WebDriver
WebDriver.Navigation, WebDriver.Options, WebDriver.TargetLocator, WebDriver.Timeouts, WebDriver.Window -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new FirefoxDriver using the {@link GeckoDriverService#createDefaultService)} server configuration.FirefoxDriver(FirefoxDriverService service) Creates a new FirefoxDriver instance.FirefoxDriver(FirefoxDriverService service, FirefoxOptions options) FirefoxDriver(FirefoxDriverService service, FirefoxOptions options, ClientConfig clientConfig) FirefoxDriver(FirefoxOptions options) Creates a new FirefoxDriver instance with the specified options. -
Method Summary
Modifier and TypeMethodDescriptionstatic RemoteWebDriverBuilderbuilder()getBiDi()Current context commands are operating on.<X> XgetFullPageScreenshotAs(OutputType<X> outputType) Capture the full page screenshot and store it in the specified location.Deprecated.Deprecated.installExtension(Path path) Installs an extension.installExtension(Path path, Boolean temporary) voidquit()Quits this driver, closing every associated window.voidsetContext(FirefoxCommandContext commandContext) Context commands are operating on.voidsetFileDetector(FileDetector detector) Set the file detector to be used when sending keyboard input.voiduninstallExtension(String extensionId) Uninstall the extension by the given identifier.Methods inherited from class org.openqa.selenium.remote.RemoteWebDriver
addVirtualAuthenticator, close, deleteDownloadableFiles, downloadFile, execute, execute, execute, executeAsyncScript, executeScript, findElement, findElements, findElements, get, getCommandExecutor, getCurrentUrl, getDownloadableFiles, getElementConverter, getErrorHandler, getExecuteMethod, getFederatedCredentialManagementDialog, getFileDetector, getPageSource, getScreenshotAs, getSessionId, getTitle, getWindowHandle, getWindowHandles, log, manage, navigate, network, perform, print, removeVirtualAuthenticator, resetCooldown, resetInputState, script, setCommandExecutor, setDelayEnabled, setElementConverter, setErrorHandler, setFoundBy, setLogLevel, setSessionId, startSession, switchTo, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.openqa.selenium.HasDownloads
requireDownloadsEnabledMethods inherited from interface org.openqa.selenium.JavascriptExecutor
executeScript, getPinnedScripts, pin, unpin
-
Constructor Details
-
FirefoxDriver
public FirefoxDriver()Creates a new FirefoxDriver using the {@link GeckoDriverService#createDefaultService)} server configuration. -
FirefoxDriver
Creates a new FirefoxDriver instance with the specified options.- Parameters:
options- The options to use.- See Also:
-
FirefoxDriver
Creates a new FirefoxDriver instance. Theservicewill be started along with the driver, and shutdown upon callingquit().- Parameters:
service- The service to use.- See Also:
-
FirefoxDriver
-
FirefoxDriver
public FirefoxDriver(FirefoxDriverService service, FirefoxOptions options, ClientConfig clientConfig)
-
-
Method Details
-
builder
-
getCapabilities
- Specified by:
getCapabilitiesin interfaceHasCapabilities- Overrides:
getCapabilitiesin classRemoteWebDriver- Returns:
- The capabilities of the current driver.
-
setFileDetector
Description copied from class:RemoteWebDriverSet the file detector to be used when sending keyboard input. By default, this is set to a file detector that does nothing.- Overrides:
setFileDetectorin classRemoteWebDriver- Parameters:
detector- The detector to use. Must not be null.- See Also:
-
getLocalStorage
Deprecated.- Specified by:
getLocalStoragein interfaceWebStorage
-
getSessionStorage
Deprecated.- Specified by:
getSessionStoragein interfaceWebStorage
-
installExtension
Description copied from interface:HasExtensionsInstalls an extension.- Specified by:
installExtensionin interfaceHasExtensions- Parameters:
path- absolute path to the extension file that should be installed.- Returns:
- the unique identifier of the installed extension.
-
installExtension
- Specified by:
installExtensionin interfaceHasExtensions
-
uninstallExtension
Description copied from interface:HasExtensionsUninstall the extension by the given identifier. This value can be found in the extension's manifest, and typically ends with "@mozilla.org".- Specified by:
uninstallExtensionin interfaceHasExtensions- Parameters:
extensionId- The unique extension identifier returned by {HasExtensions.installExtension(Path)}
-
getFullPageScreenshotAs
Capture the full page screenshot and store it in the specified location.- Specified by:
getFullPageScreenshotAsin interfaceHasFullPageScreenshot- Type Parameters:
X- Return type for getFullPageScreenshotAs.- Parameters:
outputType- target type, @see OutputType- Returns:
- Object in which is stored information about the screenshot.
- Throws:
WebDriverException- on failure.
-
getContext
Description copied from interface:HasContextCurrent context commands are operating on.- Specified by:
getContextin interfaceHasContext- Returns:
FirefoxCommandContextvalue currently operating on commands
-
setContext
Description copied from interface:HasContextContext commands are operating on.- Specified by:
setContextin interfaceHasContext- Parameters:
commandContext-FirefoxCommandContextoperating on page loaded in the browser or on browser elements hosting the page.
-
maybeGetBiDi
- Specified by:
maybeGetBiDiin interfaceHasBiDi
-
getBiDi
-
quit
public void quit()Description copied from interface:WebDriverQuits this driver, closing every associated window.- Specified by:
quitin interfaceWebDriver- Overrides:
quitin classRemoteWebDriver
-