org.openqa.selenium.htmlunit
Class HtmlUnitDriver
java.lang.Object
org.openqa.selenium.htmlunit.HtmlUnitDriver
- All Implemented Interfaces:
- HasCapabilities, HasInputDevices, FindsByCssSelector, FindsById, FindsByLinkText, FindsByName, FindsByTagName, FindsByXPath, JavascriptExecutor, SearchContext, WebDriver
public class HtmlUnitDriver
- extends Object
- implements WebDriver, JavascriptExecutor, FindsById, FindsByLinkText, FindsByXPath, FindsByName, FindsByCssSelector, FindsByTagName, HasCapabilities, HasInputDevices
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
INVALIDXPATHERROR
public static final String INVALIDXPATHERROR
- See Also:
- Constant Field Values
INVALIDSELECTIONERROR
public static final String INVALIDSELECTIONERROR
- See Also:
- Constant Field Values
HtmlUnitDriver
public HtmlUnitDriver(com.gargoylesoftware.htmlunit.BrowserVersion version)
HtmlUnitDriver
public HtmlUnitDriver()
HtmlUnitDriver
public HtmlUnitDriver(boolean enableJavascript)
HtmlUnitDriver
public HtmlUnitDriver(Capabilities capabilities)
- Note: There are two configuration modes for the HtmlUnitDriver using this constructor. The
first is where the browserName is "firefox", "internet explorer" and browserVersion denotes the
desired version. The second one is where the browserName is "htmlunit" and the browserVersion
denotes the required browser AND its version. In this mode the browserVersion could either be
"firefox" for Firefox or "internet explorer-7" for IE 7. The Remote WebDriver uses the second
mode - the first mode is deprecated and should not be used.
newWebClient
protected com.gargoylesoftware.htmlunit.WebClient newWebClient(com.gargoylesoftware.htmlunit.BrowserVersion version)
- Create the underlying webclient, but don't set any fields on it.
- Parameters:
version
- Which browser to emulate
- Returns:
- a new instance of WebClient.
modifyWebClient
protected com.gargoylesoftware.htmlunit.WebClient modifyWebClient(com.gargoylesoftware.htmlunit.WebClient client)
- Child classes can override this method to customise the webclient that the HtmlUnit driver
uses.
- Parameters:
client
- The client to modify
- Returns:
- The modified client
setProxy
public void setProxy(String host,
int port)
setAutoProxy
public void setAutoProxy(String autoProxyUrl)
getCapabilities
public Capabilities getCapabilities()
- Specified by:
getCapabilities
in interface HasCapabilities
get
public void get(String url)
- Specified by:
get
in interface WebDriver
get
protected void get(URL fullUrl)
- Allows HtmlUnit's about:blank to be loaded in the constructor, and may be useful for other
tests?
- Parameters:
fullUrl
- The URL to visit
pickWindow
protected void pickWindow()
getCurrentUrl
public String getCurrentUrl()
- Specified by:
getCurrentUrl
in interface WebDriver
getTitle
public String getTitle()
- Specified by:
getTitle
in interface WebDriver
findElement
public WebElement findElement(By by)
- Specified by:
findElement
in interface SearchContext
- Specified by:
findElement
in interface WebDriver
findElements
public List<WebElement> findElements(By by)
- Specified by:
findElements
in interface SearchContext
- Specified by:
findElements
in interface WebDriver
getPageSource
public String getPageSource()
- Specified by:
getPageSource
in interface WebDriver
close
public void close()
- Specified by:
close
in interface WebDriver
quit
public void quit()
- Specified by:
quit
in interface WebDriver
getWindowHandles
public Set<String> getWindowHandles()
- Specified by:
getWindowHandles
in interface WebDriver
getWindowHandle
public String getWindowHandle()
- Specified by:
getWindowHandle
in interface WebDriver
executeScript
public Object executeScript(String script,
Object... args)
- Specified by:
executeScript
in interface JavascriptExecutor
executeAsyncScript
public Object executeAsyncScript(String script,
Object... args)
- Specified by:
executeAsyncScript
in interface JavascriptExecutor
getKeyboard
public Keyboard getKeyboard()
- Specified by:
getKeyboard
in interface HasInputDevices
getMouse
public Mouse getMouse()
- Specified by:
getMouse
in interface HasInputDevices
switchTo
public WebDriver.TargetLocator switchTo()
- Specified by:
switchTo
in interface WebDriver
navigate
public WebDriver.Navigation navigate()
- Specified by:
navigate
in interface WebDriver
lastPage
protected com.gargoylesoftware.htmlunit.Page lastPage()
findElementByLinkText
public WebElement findElementByLinkText(String selector)
- Specified by:
findElementByLinkText
in interface FindsByLinkText
newHtmlUnitWebElement
protected WebElement newHtmlUnitWebElement(com.gargoylesoftware.htmlunit.html.HtmlElement element)
findElementsByLinkText
public List<WebElement> findElementsByLinkText(String selector)
- Specified by:
findElementsByLinkText
in interface FindsByLinkText
findElementById
public WebElement findElementById(String id)
- Specified by:
findElementById
in interface FindsById
findElementsById
public List<WebElement> findElementsById(String id)
- Specified by:
findElementsById
in interface FindsById
findElementByCssSelector
public WebElement findElementByCssSelector(String using)
- Specified by:
findElementByCssSelector
in interface FindsByCssSelector
findElementsByCssSelector
public List<WebElement> findElementsByCssSelector(String using)
- Specified by:
findElementsByCssSelector
in interface FindsByCssSelector
findElementByName
public WebElement findElementByName(String name)
- Specified by:
findElementByName
in interface FindsByName
findElementsByName
public List<WebElement> findElementsByName(String using)
- Specified by:
findElementsByName
in interface FindsByName
findElementByTagName
public WebElement findElementByTagName(String name)
- Specified by:
findElementByTagName
in interface FindsByTagName
findElementsByTagName
public List<WebElement> findElementsByTagName(String using)
- Specified by:
findElementsByTagName
in interface FindsByTagName
findElementByXPath
public WebElement findElementByXPath(String selector)
- Specified by:
findElementByXPath
in interface FindsByXPath
findElementsByXPath
public List<WebElement> findElementsByXPath(String selector)
- Specified by:
findElementsByXPath
in interface FindsByXPath
isJavascriptEnabled
public boolean isJavascriptEnabled()
setJavascriptEnabled
public void setJavascriptEnabled(boolean enableJavascript)
implicitlyWaitFor
protected <X> X implicitlyWaitFor(Callable<X> condition)
getWebClient
protected com.gargoylesoftware.htmlunit.WebClient getWebClient()
getCurrentWindow
protected com.gargoylesoftware.htmlunit.WebWindow getCurrentWindow()
manage
public WebDriver.Options manage()
- Specified by:
manage
in interface WebDriver
findElementByPartialLinkText
public WebElement findElementByPartialLinkText(String using)
- Specified by:
findElementByPartialLinkText
in interface FindsByLinkText
findElementsByPartialLinkText
public List<WebElement> findElementsByPartialLinkText(String using)
- Specified by:
findElementsByPartialLinkText
in interface FindsByLinkText
Copyright © 2012. All Rights Reserved.