Package com.facilita.fc.selenium
Class WebDriver
- java.lang.Object
-
- com.facilita.fc.selenium.WebDriver
-
- All Implemented Interfaces:
SearchContext
,WebDriver
public class WebDriver extends java.lang.Object implements WebDriver
An implementation ofWebDriver
, which represents an idealised web browser.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.openqa.selenium.WebDriver
WebDriver.ImeHandler, WebDriver.Navigation, WebDriver.Options, WebDriver.TargetLocator, WebDriver.Timeouts, WebDriver.Window
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the current window, quitting the browser if it's the last window currently open.WebElement
findElement(By by)
Find the firstWebElement
using the given method.java.util.List<WebElement>
findElements(By by)
Find all elements within the current page using the given mechanism.void
get(java.lang.String url)
Load a new web page in the current browser window.java.lang.String
getCurrentUrl()
Get a string representing the current URL that the browser is looking at.WebDriverType
getDriverType()
Get the driver type of this instance (e.g.java.lang.String
getPageSource()
Get the source of the last loaded page.java.lang.String
getTitle()
The title of the current page.java.lang.String
getWindowHandle()
Return an opaque handle to this window that uniquely identifies it within this driver instance.java.util.Set<java.lang.String>
getWindowHandles()
Return a set of window handles which can be used to iterate over all open windows of this webdriver instance.WebDriver.Options
manage()
Gets the Option interfaceWebDriver.Navigation
navigate()
An abstraction allowing the driver to access the browser's history and to navigate to a given URL.void
quit()
Quits this driver, closing every associated window.WebDriver.TargetLocator
switchTo()
Send future commands to a different frame or window.
-
-
-
Method Detail
-
get
public void get(java.lang.String url)
Load a new web page in the current browser window.
-
switchTo
public WebDriver.TargetLocator switchTo()
Send future commands to a different frame or window.
-
quit
public void quit()
Quits this driver, closing every associated window.
-
navigate
public WebDriver.Navigation navigate()
An abstraction allowing the driver to access the browser's history and to navigate to a given URL.- Specified by:
navigate
in interfaceWebDriver
- Returns:
- A
WebDriver.Navigation
that allows the selection of what to do next
-
manage
public WebDriver.Options manage()
Gets the Option interface
-
getWindowHandles
public java.util.Set<java.lang.String> getWindowHandles()
Return a set of window handles which can be used to iterate over all open windows of this webdriver instance.- Specified by:
getWindowHandles
in interfaceWebDriver
- Returns:
- A set of window handles which can be used to iterate over all open windows.
-
getWindowHandle
public java.lang.String getWindowHandle()
Return an opaque handle to this window that uniquely identifies it within this driver instance.- Specified by:
getWindowHandle
in interfaceWebDriver
- Returns:
- An opaque handle to this window that uniquely identifies it within this driver instance.
-
getTitle
public java.lang.String getTitle()
The title of the current page.
-
getPageSource
public java.lang.String getPageSource()
Get the source of the last loaded page.- Specified by:
getPageSource
in interfaceWebDriver
- Returns:
- The source of the current page
-
getCurrentUrl
public java.lang.String getCurrentUrl()
Get a string representing the current URL that the browser is looking at.- Specified by:
getCurrentUrl
in interfaceWebDriver
- Returns:
- The URL of the page currently loaded in the browser
-
findElements
public java.util.List<WebElement> findElements(By by)
Find all elements within the current page using the given mechanism.- Specified by:
findElements
in interfaceSearchContext
- Specified by:
findElements
in interfaceWebDriver
- Parameters:
by
- The locating mechanism to use- Returns:
- A list of all
WebElement
s, or an empty list if nothing matches
-
findElement
public WebElement findElement(By by)
Find the firstWebElement
using the given method.- Specified by:
findElement
in interfaceSearchContext
- Specified by:
findElement
in interfaceWebDriver
- Parameters:
by
- The locating mechanism to use- Returns:
- The first matching element on the current page
-
close
public void close()
Close the current window, quitting the browser if it's the last window currently open.
-
getDriverType
public WebDriverType getDriverType()
Get the driver type of this instance (e.g. FireFox, HtmlUnit)- Returns:
- the driver type of this instance.
-
-