clear() WebElement
WebElement
clears the elements value
element.clear()
clearValue TextInput
WebElement
clears the value of a TextInput
textInput.clearValue
click() WebElement
WebElement
clicks the element
element.click()
dispose() Session
Unit
Disposes/terminates the current session
session.dispose()
elementExists Session
By → Boolean
- By by
Uses findElements to ascertain if an element exists based on By locator
val result: Boolean = session.elementExists(By.className("some-class"))
executeAsyncScript Session
ExecuteScriptResponse
Execute some javascript asynchronously
session.executeAsyncScript("alert('woop');")
executeScript Session
ExecuteScriptResponse
Execute some javascript synchronously
session.executeScript("return $('.name');")
findAll Session
T <: Searcher → Condition → Int → List[WebElement]
- T <: Searcher element (takes an element or a By locator)
- Condition condition (defaults to isVisible)
- Int timeout (defaults to globalTimeout)
Finds all elements that matches the locator criteria The finder is more robust in that it peforms the search until it times out. It is more robust than findElements because it performs a new search each time until timeout expires.
session.findAll(By.id("some-id"))
findAll WebElement
T <: Searcher → Condition → Int → List[WebElement]
- T <: Searcher element (takes an element or a By locator)
- Condition condition (defaults to isVisible)
- Int timeout (defaults to globalTimeout)
Finds all elements that matches the locator criteria The finder is more robust in that it peforms the search until it times out. It is more robust than findElements because it performs a new search each time until timeout expires.
element.findAll(By.id("some-id"))
findElement Session
By → WebElement
- By by
Find an element using a By locator - throws an exception if not found within implicit timeout
session.findElement(By.className("some-class"))
findElements Session
By → List[WebElement]
- By by
Find all elements using a By locator - does not throw an exception if nothing found just returns an empty list
session.findElements(By.className("some-class"))
findFirst Session
T <: Searcher → Condition → Int → Option[WebElement]
- T <: Searcher element (takes an element or a By locator)
- Condition condition (defaults to isVisible)
- Int timeout (defaults to globalTimeout)
Finds an option of the first element that matches the locator criteria The finder is more robust in that it peforms the search until it times out. Since it returns an option it's useful for cases when you want to check something but not throw an exception automatically.
session.findFirst(By.id("some-id"))
findFirst WebElement
T <: Searcher → Condition → Int → Option[WebElement]
- T <: Searcher element (takes an element or a By locator)
- Condition condition (defaults to isVisible)
- Int timeout (defaults to globalTimeout)
Finds an option of the first element that matches the locator criteria The finder is more robust in that it peforms the search until it times out. Since it returns an option it's useful for cases when you want to check something but not throw an exception automatically.
element.findFirst(By.id("some-id"))
getAttributeOption WebElement
String → Option[String]
- String attribute (name of attribute)
gets an attribute of the element as an option
element.getAttributeOption("class")
getAttributeOption WebElement
String → String
- String attribute (name of attribute)
gets an attribute of the element as a string
element.getAttribute("class")
getCapabilities Session
Capabilities
Return the current capability information
session.getCapabilities()
getGlobalTimeout Session
Int
Gets the current value in millis of the global timeout
val timeout: Int = session.getGlobalTimeout
getName WebElement
String
gets the name of the element as a string
element.getName
getNameOption WebElement
Option[String]
gets the name of the element as an option
element.getNameOption
getSessions Session
List[Sessions]
Shows a list of existing sessions started by whichever driver is used: e.g. phantom, chrome
session.getSessions()
getSource Session
Option[String]
Get the source of the current page
session.getSource
getStatus Session
ServerStatus
Describes the general status of the server
session.getStatus()
getText WebElement
String
gets text of element as a string
element.getText
getTextOption WebElement
Option[String]
gets text of element as an option
element.getTextOption
getTitle Session
Option[String]
Get the title of the current page
session.getTitle
getUrl Session
Option[String]
Gets the current url of the page
session.getUrl
getValue TextInput
String
gets value from TextInput
textInput.getValue
getWindowHandle Session
WindowHandle
Gets the current window handle
session.getWindowHandle
getWindowHandles Session
List[WindowHandle]
Gets a list of open windows
session.getWindowHandles
goBack Session
Unit
Operate the browsers go back
session.goBack
goForward Session
Unit
Operate the browsers go forward
session.goForward
isButton WebElement
Boolean
checks if a WebElement is a button
element.isButton
isDisplayed WebElement
Boolean
checks if a WebElement is displayed/visible
element.isDisplayed
isEnabled WebElement
Boolean
checks if a WebElement is enabled
element.isEnabled
isLink WebElement
Boolean
checks if a WebElement is a link
element.isLink
isPresent WebElement
Boolean
checks if a WebElement is enabled and displayed
element.isPresent
isRadio WebElement
Boolean
checks if a WebElement is a radio
element.isRadio
isSelected WebElement
Boolean
checks if a WebElement is selected
element.isSelected
isTextArea WebElement
Boolean
checks if a WebElement is a text area
element.isTextArea
isTextInput WebElement
Boolean
checks if a WebElement is a text input
element.isTextInput
refresh Session
Unit
Operate the browsers refresh
session.refresh
sendKeys WebElement
String → WebElement
- String text (the string to be typed into the element)
sends keystrokes to the WebElement using a string
element.sendKeys("This is cool")
sendKeys WebElement
Keys.Value* → WebElement
- Keys.Value* key (the keys to be typed into the element)
sends keystrokes to the WebElement using Keys
element.sendKeys(Keys.TAB, Keys.ENTER)
setAllTimeouts Session
Int
- Int timeout (in millis)
Sets all the timeouts to the supplied value in millis
session.setAllTimeouts(8000)
setAsyncScriptTimeout Session
Int → Unit
- Int milliseconds
Set a timeout for async script execution
session.setAsyncScriptTimeout(5000)
setGlobalTimeout Session
Int
- Int timeout (in millis, defaults to 5000)
Sets the timeout used in all the functions that perform an internal timeout while waiting for something
session.setGlobalTimeout(8000)
setImplicitWaitTimeout Session
Int → Unit
- Int milliseconds
Set a timeout for implicit wait
session.setImplicitWaitTimeout(5000)
setTimeout Session
TimeoutType → Int → Unit
- TimeoutType timeoutType
- Int milliseconds
Set a timeout for a specific TimeoutType
session.setTimeout(TimeoutType.IMPLICIT, 5000)
setValue TextInput
String → WebElement
- String value
sets the value of a TextInput
textInput.setValue("some value")
takeScreenshot Session
String → Unit
- String outputFile (defaults to screenshot.png)
Take a screenshot
session.takeScreenshot("some-file.png")
toButton WebElement
Button
converts a WebElement to a Button
element.toButton
toLink WebElement
Link
converts a WebElement to a Link
element.toLink
toRadio WebElement
Radio
converts a WebElement to a Radio
element.toRadio
toTextArea WebElement
TextArea
converts a WebElement to a TextArea
element.toTextArea
toTextInput WebElement
TextInput
converts a WebElement to a TextInput
element.toTextInput
visitUrl Session
String → Session
- String url
Navigate to the supplied url
session.visitUrl("www.google.com")
waitFor Session
T <: Searcher → Condition → Int → WebElement
- T <: Searcher element (takes an element or a By locator)
- Condition condition (defaults to isVisible)
- Int timeout (defaults to globalTimeout)
Wait for condition to be satisfied
// using By locator with default Condition.isVisible
val ele1: WebElement = session.waitFor(By.id("username"))
// using By locator with a Condition
val ele2: WebElement = session.waitFor(By.id("username"), Condition.isEnabled)
// using an element
val ele3: WebElement = session.waitFor(ele1)
// using an element with a Condition
val ele4: WebElement = session.waitFor(ele1, Condition.textContains("hello"))
waitFor WebElement
T <: Searcher → Condition → Int → WebElement
- T <: Searcher element (takes an element or a By locator)
- Condition condition (defaults to isVisible)
- Int timeout (defaults to globalTimeout)
Wait for condition to be satisfied
// using By locator with default Condition.isVisible
val ele1 = element.waitFor(By.id("username"))
// using By locator with a Condition
element.waitFor(By.id("username"), Condition.isEnabled)
// using an element
element.waitFor(ele1)
// using an element with a Condition
element.waitFor(ele1, Condition.textContains("hello"))
waitForClass Session
String → Condition → Int → WebElement
- String className
- Condition condition (defaults to isVisible)
- Int timeout (defaults to globalTimeout)
A shortcut to waitFor using a classname
session.waitForClass("some-classname")
waitForClass WebElement
String → Condition → Int → WebElement
- String className
- Condition condition (defaults to isVisible)
- Int timeout (defaults to globalTimeout)
A shortcut to waitFor using a classname
element.waitForClass("some-classname")
waitForCss Session
String → Condition → Int → WebElement
- String cssSelector
- Condition condition (defaults to isVisible)
- Int timeout (defaults to globalTimeout)
A shortcut to waitFor using css selector
session.waitForCss("some-css-selector")
waitForCss WebElement
String → Condition → Int → WebElement
- String cssSelector
- Condition condition (defaults to isVisible)
- Int timeout (defaults to globalTimeout)
A shortcut to waitFor using css selector
element.waitForCss("some-css-selector")
waitForFunction Session
() => Result → Int → Unit
- () => Result runnable (supply the function here - see example)
- Int timeout (defaults to globalTimeout)
Peforms the supplied function until the timeout occurs or the function is satisfied. This is very useful for writing custom waitFor code where Erika doesn't supply a suitable method
// This shows how the waitForUrl is implemented - you must return a Result from the function
val waitForUrlFunction: () => Result = () => {
val actualUrl = this.getUrl.getOrElse("")
val outcome: Boolean = expectedUrl == actualUrl
if(outcome) Result(outcome, actualUrl) else Result(outcome, s"Error: expected url: $expectedUrl but got url: $actualUrl")
}
session.waitForFunction(waitForUrlFunction)
waitForFunction WebElement
() => Result → Int → Unit
- () => Result runnable (supply the function here - see example)
- Int timeout (defaults to globalTimeout)
Peforms the supplied function until the timeout occurs or the function is satisfied. This is very useful for writing custom waitFor code where Erika doesn't supply a suitable method
// This shows how the waitForUrl is implemented - you must return a Result from the function
val waitForUrlFunction: () => Result = () => {
val actualUrl = this.getUrl.getOrElse("")
val outcome: Boolean = expectedUrl == actualUrl
if(outcome) Result(outcome, actualUrl) else Result(outcome, s"Error: expected url: $expectedUrl but got url: $actualUrl")
}
element.waitForFunction(waitForUrlFunction)
waitForId Session
String → Condition → Int → WebElement
- String id
- Condition condition (defaults to isVisible)
- Int timeout (defaults to globalTimeout)
A shortcut to waitFor using an Id
session.waitForId("some-id")
waitForId WebElement
String → Condition → Int → WebElement
- String id
- Condition condition (defaults to isVisible)
- Int timeout (defaults to globalTimeout)
A shortcut to waitFor using an Id
element.waitForId("some-id")
waitForLink Session
String → Condition → Int → WebElement
- String linkText
- Condition condition (defaults to isVisible)
- Int timeout (defaults to globalTimeout)
A shortcut to waitFor using link text
session.waitForLink("some link text")
waitForLink WebElement
String → Condition → Int → WebElement
- String linkText
- Condition condition (defaults to isVisible)
- Int timeout (defaults to globalTimeout)
A shortcut to waitFor using link text
element.waitForLink("some link text")
waitForLinkP Session
String → Condition → Int → WebElement
- String partialLinkText
- Condition condition (defaults to isVisible)
- Int timeout (defaults to globalTimeout)
A shortcut to waitFor using partial link text
session.waitForLinkP("some partial link text")
waitForLinkP WebElement
String → Condition → Int → WebElement
- String partialLinkText
- Condition condition (defaults to isVisible)
- Int timeout (defaults to globalTimeout)
A shortcut to waitFor using partial link text
element.waitForLinkP("some partial link text")
waitForName Session
String → Condition → Int → WebElement
- String name
- Condition condition (defaults to isVisible)
- Int timeout (defaults to globalTimeout)
A shortcut to waitFor using name
session.waitForName("some-name")
waitForName WebElement
String → Condition → Int → WebElement
- String name
- Condition condition (defaults to isVisible)
- Int timeout (defaults to globalTimeout)
A shortcut to waitFor using name
element.waitForName("some-name")
waitForTag Session
String → Condition → Int → WebElement
- String tagName
- Condition condition (defaults to isVisible)
- Int timeout (defaults to globalTimeout)
A shortcut to waitFor using a tag name
session.waitForTag("input")
waitForTag WebElement
String → Condition → Int → WebElement
- String tagName
- Condition condition (defaults to isVisible)
- Int timeout (defaults to globalTimeout)
A shortcut to waitFor using a tag name
element.waitForTag("input")
waitForUrl Session
String
- String url (url to wait for)
wait for the page to have the supplied url
session.waitForUrl("http://www.some-url.com")
waitForXpath Session
String → Condition → Int → WebElement
- String xpath
- Condition condition (defaults to isVisible)
- Int timeout (defaults to globalTimeout)
A shortcut to waitFor using an xpath
session.waitForXpath("//some/xpath")
waitForXpath WebElement
String → Condition → Int → WebElement
- String xpath
- Condition condition (defaults to isVisible)
- Int timeout (defaults to globalTimeout)
A shortcut to waitFor using an xpath
element.waitForXpath("//some/xpath")