Package org.openqa.selenium.firefox
Class FirefoxDriver
- java.lang.Object
-
- org.openqa.selenium.remote.RemoteWebDriver
-
- org.openqa.selenium.firefox.FirefoxDriver
-
- All Implemented Interfaces:
HasBiDi
,HasDevTools
,HasContext
,HasExtensions
,HasFullPageScreenshot
,HasCapabilities
,WebStorage
,Interactive
,JavascriptExecutor
,PrintsPage
,SearchContext
,TakesScreenshot
,HasVirtualAuthenticator
,WebDriver
public class FirefoxDriver extends RemoteWebDriver implements WebStorage, HasExtensions, HasFullPageScreenshot, HasContext, HasDevTools, 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 theFirefoxOptions
, 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 Classes Modifier and Type Class Description static class
FirefoxDriver.SystemProperty
-
Nested classes/interfaces inherited from class org.openqa.selenium.remote.RemoteWebDriver
RemoteWebDriver.RemoteTargetLocator, RemoteWebDriver.RemoteWebDriverOptions, RemoteWebDriver.When
-
Nested classes/interfaces inherited from interface org.openqa.selenium.WebDriver
WebDriver.Navigation, WebDriver.Options, WebDriver.TargetLocator, WebDriver.Timeouts, WebDriver.Window
-
-
Constructor Summary
Constructors Constructor Description FirefoxDriver()
Creates 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
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static RemoteWebDriverBuilder
builder()
BiDi
getBiDi()
Capabilities
getCapabilities()
FirefoxCommandContext
getContext()
Current context commands are operating on.DevTools
getDevTools()
Deprecated.Use W3C-compliant BiDi protocol.<X> X
getFullPageScreenshotAs(OutputType<X> outputType)
Capture the full page screenshot and store it in the specified location.LocalStorage
getLocalStorage()
SessionStorage
getSessionStorage()
java.lang.String
installExtension(java.nio.file.Path path)
Installs an extension.java.lang.String
installExtension(java.nio.file.Path path, java.lang.Boolean temporary)
java.util.Optional<BiDi>
maybeGetBiDi()
java.util.Optional<DevTools>
maybeGetDevTools()
Deprecated.Use W3C-compliant BiDi protocol.void
quit()
Quits this driver, closing every associated window.void
setContext(FirefoxCommandContext commandContext)
Context commands are operating on.void
setFileDetector(FileDetector detector)
Set the file detector to be used when sending keyboard input.void
uninstallExtension(java.lang.String extensionId)
Uninstall the extension by the given identifier.-
Methods inherited from class org.openqa.selenium.remote.RemoteWebDriver
addVirtualAuthenticator, close, execute, execute, execute, executeAsyncScript, executeScript, findElement, findElement, findElements, findElements, findElements, get, getCommandExecutor, getCurrentUrl, getElementConverter, getErrorHandler, getExecuteMethod, getFileDetector, getPageSource, getScreenshotAs, getSessionId, getTitle, getWindowHandle, getWindowHandles, log, manage, navigate, perform, print, removeVirtualAuthenticator, resetInputState, setCommandExecutor, setElementConverter, setErrorHandler, setFoundBy, setLogLevel, setSessionId, startSession, switchTo, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.openqa.selenium.JavascriptExecutor
executeScript, getPinnedScripts, pin, unpin
-
-
-
-
Constructor Detail
-
FirefoxDriver
public FirefoxDriver()
Creates a new FirefoxDriver using the {@link GeckoDriverService#createDefaultService)} server configuration.
-
FirefoxDriver
public FirefoxDriver(FirefoxOptions options)
Creates a new FirefoxDriver instance with the specified options.- Parameters:
options
- The options to use.- See Also:
FirefoxDriver(FirefoxDriverService, FirefoxOptions)
-
FirefoxDriver
public FirefoxDriver(FirefoxDriverService service)
Creates a new FirefoxDriver instance. Theservice
will be started along with the driver, and shutdown upon callingquit()
.- Parameters:
service
- The service to use.- See Also:
RemoteWebDriver(org.openqa.selenium.remote.CommandExecutor, Capabilities)
-
FirefoxDriver
public FirefoxDriver(FirefoxDriverService service, FirefoxOptions options)
-
FirefoxDriver
public FirefoxDriver(FirefoxDriverService service, FirefoxOptions options, ClientConfig clientConfig)
-
-
Method Detail
-
builder
@Beta public static RemoteWebDriverBuilder builder()
-
getCapabilities
public Capabilities getCapabilities()
- Specified by:
getCapabilities
in interfaceHasCapabilities
- Overrides:
getCapabilities
in classRemoteWebDriver
- Returns:
- The capabilities of the current driver.
-
setFileDetector
public void setFileDetector(FileDetector detector)
Description copied from class:RemoteWebDriver
Set the file detector to be used when sending keyboard input. By default, this is set to a file detector that does nothing.- Overrides:
setFileDetector
in classRemoteWebDriver
- Parameters:
detector
- The detector to use. Must not be null.- See Also:
FileDetector
,LocalFileDetector
,UselessFileDetector
-
getLocalStorage
public LocalStorage getLocalStorage()
- Specified by:
getLocalStorage
in interfaceWebStorage
-
getSessionStorage
public SessionStorage getSessionStorage()
- Specified by:
getSessionStorage
in interfaceWebStorage
-
installExtension
public java.lang.String installExtension(java.nio.file.Path path)
Description copied from interface:HasExtensions
Installs an extension.- Specified by:
installExtension
in interfaceHasExtensions
- Parameters:
path
- absolute path to the extension file that should be installed.- Returns:
- the unique identifier of the installed extension.
-
installExtension
public java.lang.String installExtension(java.nio.file.Path path, java.lang.Boolean temporary)
- Specified by:
installExtension
in interfaceHasExtensions
-
uninstallExtension
public void uninstallExtension(java.lang.String extensionId)
Description copied from interface:HasExtensions
Uninstall the extension by the given identifier. This value can be found in the extension's manifest, and typically ends with "@mozilla.org".- Specified by:
uninstallExtension
in interfaceHasExtensions
- Parameters:
extensionId
- The unique extension identifier returned by {HasExtensions.installExtension(Path)
}
-
getFullPageScreenshotAs
public <X> X getFullPageScreenshotAs(OutputType<X> outputType) throws WebDriverException
Capture the full page screenshot and store it in the specified location.- Specified by:
getFullPageScreenshotAs
in 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
public FirefoxCommandContext getContext()
Description copied from interface:HasContext
Current context commands are operating on.- Specified by:
getContext
in interfaceHasContext
- Returns:
FirefoxCommandContext
value currently operating on commands
-
setContext
public void setContext(FirefoxCommandContext commandContext)
Description copied from interface:HasContext
Context commands are operating on.- Specified by:
setContext
in interfaceHasContext
- Parameters:
commandContext
-FirefoxCommandContext
operating on page loaded in the browser or on browser elements hosting the page.
-
maybeGetDevTools
@Deprecated public java.util.Optional<DevTools> maybeGetDevTools()
Deprecated.Use W3C-compliant BiDi protocol. Use {maybeGetBiDi()
}- Specified by:
maybeGetDevTools
in interfaceHasDevTools
-
getDevTools
@Deprecated public DevTools getDevTools()
Deprecated.Use W3C-compliant BiDi protocol. Use {getBiDi()
}- Specified by:
getDevTools
in interfaceHasDevTools
-
maybeGetBiDi
public java.util.Optional<BiDi> maybeGetBiDi()
- Specified by:
maybeGetBiDi
in interfaceHasBiDi
-
quit
public void quit()
Description copied from interface:WebDriver
Quits this driver, closing every associated window.- Specified by:
quit
in interfaceWebDriver
- Overrides:
quit
in classRemoteWebDriver
-
-