public class PhantomJSDriver
extends org.openqa.selenium.remote.RemoteWebDriver
implements org.openqa.selenium.TakesScreenshot
WebDriver
implementation that controls a PhantomJS running in Remote WebDriver mode.
This class is provided as a convenience for easily testing PhantomJS.
The control server which each instance communicates with will live and die with the instance.
The Driver requires to optionally set some Capabilities or Environment Variables:
PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY
PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_PATH_PROPERTY
PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY
is required only if the executable
phantomjs
is not available through the $PATH
environment variable:
you can provide it either via the Capabilities
construction parameter object,
or via System
Property.
PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_PATH_PROPERTY
is optional in case you want to use a specific
version of GhostDriver (i.e. during development of GhostDriver).
You can provide it either via the Capabilities
construction parameter object,
or via System
Property.
Instead, if you have a PhantomJS WebDriver process already running, you can instead use RemoteWebDriver.RemoteWebDriver(java.net.URL, org.openqa.selenium.Capabilities)
to delegate the
execution of your WebDriver/Selenium scripts to it. Of course, in that case you will than be in
charge to control the life-cycle of the PhantomJS process.
NOTE: PhantomJS Remote WebDriver mode is implemented via
GhostDriver.
It's a separate project that, at every stable release, is merged into PhantomJS.
If interested in developing (contributing to) GhostDriver, it's possible to run PhantomJS and pass GhostDriver as
a script.
NOTE: The design of this class is heavily inspired by org.openqa.selenium.chrome.ChromeDriver
.org.openqa.selenium.remote.RemoteWebDriver.RemoteTargetLocator, org.openqa.selenium.remote.RemoteWebDriver.RemoteWebDriverOptions, org.openqa.selenium.remote.RemoteWebDriver.When
org.openqa.selenium.WebDriver.ImeHandler, org.openqa.selenium.WebDriver.Navigation, org.openqa.selenium.WebDriver.Options, org.openqa.selenium.WebDriver.TargetLocator, org.openqa.selenium.WebDriver.Timeouts, org.openqa.selenium.WebDriver.Window
Constructor and Description |
---|
PhantomJSDriver(org.openqa.selenium.Capabilities desiredCapabilities)
Creates a new PhantomJSDriver instance.
|
PhantomJSDriver(PhantomJSDriverService service,
org.openqa.selenium.Capabilities desiredCapabilities)
Creates a new PhantomJSDriver instance.
|
Modifier and Type | Method and Description |
---|---|
<X> X |
getScreenshotAs(org.openqa.selenium.OutputType<X> target)
Take screenshot of the current window.
|
close, execute, execute, executeAsyncScript, executeScript, findElement, findElement, findElementByClassName, findElementByCssSelector, findElementById, findElementByLinkText, findElementByName, findElementByPartialLinkText, findElementByTagName, findElementByXPath, findElements, findElements, findElementsByClassName, findElementsByCssSelector, findElementsById, findElementsByLinkText, findElementsByName, findElementsByPartialLinkText, findElementsByTagName, findElementsByXPath, get, getCapabilities, getCommandExecutor, getCurrentUrl, getElementConverter, getErrorHandler, getExecuteMethod, getFileDetector, getKeyboard, getMouse, getPageSource, getSessionId, getTitle, getWindowHandle, getWindowHandles, log, manage, navigate, quit, setCommandExecutor, setElementConverter, setFileDetector, setFoundBy, setLogLevel, setSessionId, startClient, startSession, startSession, stopClient, switchTo, toString
public PhantomJSDriver(org.openqa.selenium.Capabilities desiredCapabilities)
desiredCapabilities
- The capabilities required from PhantomJS/GhostDriver.for configuration details.
public PhantomJSDriver(PhantomJSDriverService service, org.openqa.selenium.Capabilities desiredCapabilities)
service
will be started along with the
driver, and shutdown upon calling RemoteWebDriver.quit()
.service
- The service to use.desiredCapabilities
- The capabilities required from PhantomJS/GhostDriver.public <X> X getScreenshotAs(org.openqa.selenium.OutputType<X> target) throws org.openqa.selenium.WebDriverException
getScreenshotAs
in interface org.openqa.selenium.TakesScreenshot
target
- The target type/format of the Screenshotorg.openqa.selenium.WebDriverException
TakesScreenshot.getScreenshotAs(org.openqa.selenium.OutputType)