public class HtmlUnitLocalDriver extends Object implements org.openqa.selenium.WebDriver, org.openqa.selenium.JavascriptExecutor, org.openqa.selenium.internal.FindsById, org.openqa.selenium.internal.FindsByLinkText, org.openqa.selenium.internal.FindsByXPath, org.openqa.selenium.internal.FindsByName, org.openqa.selenium.internal.FindsByCssSelector, org.openqa.selenium.internal.FindsByTagName, org.openqa.selenium.internal.FindsByClassName, org.openqa.selenium.HasCapabilities, org.openqa.selenium.interactions.HasInputDevices
WebDriver that drives HtmlUnit,
which is a headless (GUI-less) browser simulator.
The main supported browsers are Chrome, Firefox and Internet Explorer.
| Modifier and Type | Class and Description |
|---|---|
class |
HtmlUnitLocalDriver.HtmlUnitWindow |
protected static interface |
HtmlUnitLocalDriver.JavaScriptResultsCollection |
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| Modifier and Type | Field and Description |
|---|---|
static String |
BROWSER_LANGUAGE_CAPABILITY |
static String |
DOWNLOAD_IMAGES_CAPABILITY |
static String |
INVALIDSELECTIONERROR |
static String |
INVALIDXPATHERROR |
static String |
JAVASCRIPT_ENABLED |
| Constructor and Description |
|---|
HtmlUnitLocalDriver()
Constructs a new instance with JavaScript disabled,
and the
default BrowserVersion. |
HtmlUnitLocalDriver(boolean enableJavascript)
Constructs a new instance, specify JavaScript support
and using the
default BrowserVersion. |
HtmlUnitLocalDriver(com.gargoylesoftware.htmlunit.BrowserVersion version)
Constructs a new instance with the specified
BrowserVersion. |
HtmlUnitLocalDriver(com.gargoylesoftware.htmlunit.BrowserVersion version,
boolean enableJavascript)
Constructs a new instance with the specified
BrowserVersion and the JavaScript support. |
HtmlUnitLocalDriver(org.openqa.selenium.Capabilities capabilities)
Note: There are two configuration modes for the HtmlUnitDriver using this constructor.
|
HtmlUnitLocalDriver(org.openqa.selenium.Capabilities desiredCapabilities,
org.openqa.selenium.Capabilities requiredCapabilities) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
assertElementNotStale(com.gargoylesoftware.htmlunit.html.DomElement element) |
protected void |
buttondown() |
protected void |
buttonup() |
protected void |
click(HtmlUnitWebElement element) |
protected void |
click(int button) |
void |
close() |
protected void |
doubleclick() |
Object |
executeAsyncScript(String script,
Object... args) |
Object |
executeScript(String script,
Object... args) |
org.openqa.selenium.WebElement |
findElement(org.openqa.selenium.By by) |
org.openqa.selenium.WebElement |
findElementByClassName(String className) |
org.openqa.selenium.WebElement |
findElementByCssSelector(String using) |
org.openqa.selenium.WebElement |
findElementById(String id) |
org.openqa.selenium.WebElement |
findElementByLinkText(String selector) |
org.openqa.selenium.WebElement |
findElementByName(String name) |
org.openqa.selenium.WebElement |
findElementByPartialLinkText(String using) |
org.openqa.selenium.WebElement |
findElementByTagName(String name) |
org.openqa.selenium.WebElement |
findElementByXPath(String selector) |
List<org.openqa.selenium.WebElement> |
findElements(org.openqa.selenium.By by) |
List<org.openqa.selenium.WebElement> |
findElementsByClassName(String className) |
List<org.openqa.selenium.WebElement> |
findElementsByCssSelector(String using) |
List<org.openqa.selenium.WebElement> |
findElementsById(String id) |
List<org.openqa.selenium.WebElement> |
findElementsByLinkText(String selector) |
List<org.openqa.selenium.WebElement> |
findElementsByName(String name) |
List<org.openqa.selenium.WebElement> |
findElementsByPartialLinkText(String using) |
List<org.openqa.selenium.WebElement> |
findElementsByTagName(String name) |
List<org.openqa.selenium.WebElement> |
findElementsByXPath(String selector) |
void |
get(String url) |
protected void |
get(URL fullUrl)
Allows HtmlUnit's about:blank to be loaded in the constructor, and may be useful for other
tests?
|
com.gargoylesoftware.htmlunit.BrowserVersion |
getBrowserVersion()
Get the simulated
BrowserVersion. |
org.openqa.selenium.Capabilities |
getCapabilities() |
String |
getCurrentUrl() |
protected com.gargoylesoftware.htmlunit.WebWindow |
getCurrentWindow() |
protected HtmlUnitWebElement |
getElementById(int id) |
org.openqa.selenium.interactions.Keyboard |
getKeyboard() |
org.openqa.selenium.interactions.Mouse |
getMouse() |
String |
getPageSource() |
String |
getTitle() |
protected com.gargoylesoftware.htmlunit.WebClient |
getWebClient() |
String |
getWindowHandle() |
Set<String> |
getWindowHandles() |
protected <X> X |
implicitlyWaitFor(Callable<X> condition) |
boolean |
isDownloadImages() |
boolean |
isJavascriptEnabled() |
protected void |
keys(String string) |
protected com.gargoylesoftware.htmlunit.Page |
lastPage() |
org.openqa.selenium.WebDriver.Options |
manage() |
protected com.gargoylesoftware.htmlunit.WebClient |
modifyWebClient(com.gargoylesoftware.htmlunit.WebClient client)
Child classes can override this method to customize the WebClient that the HtmlUnit driver
uses.
|
protected void |
moveTo(int elementId) |
org.openqa.selenium.WebDriver.Navigation |
navigate() |
protected com.gargoylesoftware.htmlunit.WebClient |
newWebClient(com.gargoylesoftware.htmlunit.BrowserVersion version)
Create the underlying WebClient, but don't set any fields on it.
|
protected void |
pickWindow() |
void |
quit() |
void |
setAutoProxy(String autoProxyUrl)
Sets Proxy Autoconfiguration URL for WebClient
|
void |
setDownloadImages(boolean downloadImages) |
void |
setHTTPProxy(String host,
int port,
List<String> noProxyHosts)
Sets HTTP proxy for WebClient with bypass proxy hosts
|
void |
setJavascriptEnabled(boolean enableJavascript) |
void |
setProxy(String host,
int port)
Sets HTTP proxy for WebClient
|
void |
setProxySettings(org.openqa.selenium.Proxy proxy)
Set proxy for WebClient using Proxy.
|
void |
setSocksProxy(String host,
int port)
Sets SOCKS proxy for WebClient
|
void |
setSocksProxy(String host,
int port,
List<String> noProxyHosts)
Sets SOCKS proxy for WebClient with bypass proxy hosts
|
org.openqa.selenium.WebDriver.TargetLocator |
switchTo() |
protected org.openqa.selenium.WebElement |
toWebElement(com.gargoylesoftware.htmlunit.html.DomElement element) |
public static final String INVALIDXPATHERROR
public static final String INVALIDSELECTIONERROR
public static final String BROWSER_LANGUAGE_CAPABILITY
public static final String DOWNLOAD_IMAGES_CAPABILITY
public static final String JAVASCRIPT_ENABLED
public HtmlUnitLocalDriver()
default BrowserVersion.public HtmlUnitLocalDriver(boolean enableJavascript)
default BrowserVersion.enableJavascript - whether to enable JavaScript support or notpublic HtmlUnitLocalDriver(com.gargoylesoftware.htmlunit.BrowserVersion version,
boolean enableJavascript)
BrowserVersion and the JavaScript support.version - the browser version to useenableJavascript - whether to enable JavaScript support or notpublic HtmlUnitLocalDriver(com.gargoylesoftware.htmlunit.BrowserVersion version)
BrowserVersion.version - the browser version to usepublic HtmlUnitLocalDriver(org.openqa.selenium.Capabilities capabilities)
The Remote WebDriver uses the second mode - the first mode is deprecated and should not be used.
capabilities - desired capabilities requested for the htmlunit driver sessionpublic HtmlUnitLocalDriver(org.openqa.selenium.Capabilities desiredCapabilities,
org.openqa.selenium.Capabilities requiredCapabilities)
public com.gargoylesoftware.htmlunit.BrowserVersion getBrowserVersion()
BrowserVersion.BrowserVersionprotected com.gargoylesoftware.htmlunit.WebClient newWebClient(com.gargoylesoftware.htmlunit.BrowserVersion version)
version - Which browser to emulateprotected com.gargoylesoftware.htmlunit.WebClient modifyWebClient(com.gargoylesoftware.htmlunit.WebClient client)
client - The client to modifypublic void setProxySettings(org.openqa.selenium.Proxy proxy)
proxy - The proxy preferences.public void setProxy(String host, int port)
host - The hostname of HTTP proxyport - The port of HTTP proxy, 0 means HTTP proxy w/o portpublic void setHTTPProxy(String host, int port, List<String> noProxyHosts)
host - The hostname of HTTP proxyport - The port of HTTP proxy, 0 means HTTP proxy w/o portnoProxyHosts - The list of hosts which need to bypass HTTP proxypublic void setSocksProxy(String host, int port)
host - The hostname of SOCKS proxyport - The port of SOCKS proxy, 0 means HTTP proxy w/o portpublic void setSocksProxy(String host, int port, List<String> noProxyHosts)
host - The hostname of SOCKS proxyport - The port of SOCKS proxy, 0 means HTTP proxy w/o portnoProxyHosts - The list of hosts which need to bypass SOCKS proxypublic void setAutoProxy(String autoProxyUrl)
autoProxyUrl - The Proxy Autoconfiguration URLpublic org.openqa.selenium.Capabilities getCapabilities()
getCapabilities in interface org.openqa.selenium.HasCapabilitiespublic void get(String url)
get in interface org.openqa.selenium.WebDriverprotected void get(URL fullUrl)
fullUrl - The URL to visitprotected void pickWindow()
public String getCurrentUrl()
getCurrentUrl in interface org.openqa.selenium.WebDriverpublic String getTitle()
getTitle in interface org.openqa.selenium.WebDriverpublic org.openqa.selenium.WebElement findElement(org.openqa.selenium.By by)
findElement in interface org.openqa.selenium.SearchContextfindElement in interface org.openqa.selenium.WebDriverpublic List<org.openqa.selenium.WebElement> findElements(org.openqa.selenium.By by)
findElements in interface org.openqa.selenium.SearchContextfindElements in interface org.openqa.selenium.WebDriverpublic String getPageSource()
getPageSource in interface org.openqa.selenium.WebDriverpublic void close()
close in interface org.openqa.selenium.WebDriverpublic void quit()
quit in interface org.openqa.selenium.WebDriverpublic Set<String> getWindowHandles()
getWindowHandles in interface org.openqa.selenium.WebDriverpublic String getWindowHandle()
getWindowHandle in interface org.openqa.selenium.WebDriverpublic Object executeScript(String script, Object... args)
executeScript in interface org.openqa.selenium.JavascriptExecutorpublic Object executeAsyncScript(String script, Object... args)
executeAsyncScript in interface org.openqa.selenium.JavascriptExecutorprotected void assertElementNotStale(com.gargoylesoftware.htmlunit.html.DomElement element)
public org.openqa.selenium.interactions.Keyboard getKeyboard()
getKeyboard in interface org.openqa.selenium.interactions.HasInputDevicespublic org.openqa.selenium.interactions.Mouse getMouse()
getMouse in interface org.openqa.selenium.interactions.HasInputDevicespublic org.openqa.selenium.WebDriver.TargetLocator switchTo()
switchTo in interface org.openqa.selenium.WebDriverpublic org.openqa.selenium.WebDriver.Navigation navigate()
navigate in interface org.openqa.selenium.WebDriverprotected com.gargoylesoftware.htmlunit.Page lastPage()
public org.openqa.selenium.WebElement findElementByLinkText(String selector)
findElementByLinkText in interface org.openqa.selenium.internal.FindsByLinkTextprotected org.openqa.selenium.WebElement toWebElement(com.gargoylesoftware.htmlunit.html.DomElement element)
protected HtmlUnitWebElement getElementById(int id)
protected void moveTo(int elementId)
protected void click(int button)
protected void doubleclick()
protected void click(HtmlUnitWebElement element)
protected void buttondown()
protected void buttonup()
protected void keys(String string)
public List<org.openqa.selenium.WebElement> findElementsByLinkText(String selector)
findElementsByLinkText in interface org.openqa.selenium.internal.FindsByLinkTextpublic org.openqa.selenium.WebElement findElementById(String id)
findElementById in interface org.openqa.selenium.internal.FindsByIdpublic List<org.openqa.selenium.WebElement> findElementsById(String id)
findElementsById in interface org.openqa.selenium.internal.FindsByIdpublic org.openqa.selenium.WebElement findElementByClassName(String className)
findElementByClassName in interface org.openqa.selenium.internal.FindsByClassNamepublic List<org.openqa.selenium.WebElement> findElementsByClassName(String className)
findElementsByClassName in interface org.openqa.selenium.internal.FindsByClassNamepublic org.openqa.selenium.WebElement findElementByCssSelector(String using)
findElementByCssSelector in interface org.openqa.selenium.internal.FindsByCssSelectorpublic List<org.openqa.selenium.WebElement> findElementsByCssSelector(String using)
findElementsByCssSelector in interface org.openqa.selenium.internal.FindsByCssSelectorpublic org.openqa.selenium.WebElement findElementByName(String name)
findElementByName in interface org.openqa.selenium.internal.FindsByNamepublic List<org.openqa.selenium.WebElement> findElementsByName(String name)
findElementsByName in interface org.openqa.selenium.internal.FindsByNamepublic org.openqa.selenium.WebElement findElementByTagName(String name)
findElementByTagName in interface org.openqa.selenium.internal.FindsByTagNamepublic List<org.openqa.selenium.WebElement> findElementsByTagName(String name)
findElementsByTagName in interface org.openqa.selenium.internal.FindsByTagNamepublic org.openqa.selenium.WebElement findElementByXPath(String selector)
findElementByXPath in interface org.openqa.selenium.internal.FindsByXPathpublic List<org.openqa.selenium.WebElement> findElementsByXPath(String selector)
findElementsByXPath in interface org.openqa.selenium.internal.FindsByXPathpublic boolean isJavascriptEnabled()
public void setJavascriptEnabled(boolean enableJavascript)
public boolean isDownloadImages()
public void setDownloadImages(boolean downloadImages)
protected <X> X implicitlyWaitFor(Callable<X> condition)
protected com.gargoylesoftware.htmlunit.WebClient getWebClient()
protected com.gargoylesoftware.htmlunit.WebWindow getCurrentWindow()
public org.openqa.selenium.WebDriver.Options manage()
manage in interface org.openqa.selenium.WebDriverpublic org.openqa.selenium.WebElement findElementByPartialLinkText(String using)
findElementByPartialLinkText in interface org.openqa.selenium.internal.FindsByLinkTextCopyright © 2017. All rights reserved.