clear() WebElement

WebElement
Parameters
Returns WebElement

clears the elements value

element.clear()

clearValue TextInput

WebElement
Parameters
Returns WebElement

clears the value of a TextInput

textInput.clearValue

click() WebElement

WebElement
Parameters
Returns WebElement

clicks the element

element.click()

dispose() Session

Unit
Parameters
Returns Unit

Disposes/terminates the current session

session.dispose()

elementExists Session

By → Boolean
Parameters
  • By by
Returns Boolean

Uses findElements to ascertain if an element exists based on By locator

See also:
val result: Boolean = session.elementExists(By.className("some-class"))

executeAsyncScript Session

ExecuteScriptResponse
Parameters
Returns ExecuteScriptResponse

Execute some javascript asynchronously

session.executeAsyncScript("alert('woop');")

executeScript Session

ExecuteScriptResponse
Parameters
Returns ExecuteScriptResponse

Execute some javascript synchronously

session.executeScript("return $('.name');")

findAll Session

T <: Searcher → Condition → Int → List[WebElement]
Parameters
  • T <: Searcher element (takes an element or a By locator)
  • Condition condition (defaults to isVisible)
  • Int timeout (defaults to globalTimeout)
Returns List[WebElement]

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]
Parameters
  • T <: Searcher element (takes an element or a By locator)
  • Condition condition (defaults to isVisible)
  • Int timeout (defaults to globalTimeout)
Returns List[WebElement]

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
Parameters
  • By by
Returns WebElement

Find an element using a By locator - throws an exception if not found within implicit timeout

See also:
session.findElement(By.className("some-class"))

findElements Session

By → List[WebElement]
Parameters
  • By by
Returns List[WebElement]

Find all elements using a By locator - does not throw an exception if nothing found just returns an empty list

See also:
session.findElements(By.className("some-class"))

findFirst Session

T <: Searcher → Condition → Int → Option[WebElement]
Parameters
  • T <: Searcher element (takes an element or a By locator)
  • Condition condition (defaults to isVisible)
  • Int timeout (defaults to globalTimeout)
Returns Option[WebElement]

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]
Parameters
  • T <: Searcher element (takes an element or a By locator)
  • Condition condition (defaults to isVisible)
  • Int timeout (defaults to globalTimeout)
Returns Option[WebElement]

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]
Parameters
  • String attribute (name of attribute)
Returns Option[String]

gets an attribute of the element as an option

element.getAttributeOption("class")

getAttributeOption WebElement

String → String
Parameters
  • String attribute (name of attribute)
Returns String

gets an attribute of the element as a string

element.getAttribute("class")

getCapabilities Session

Capabilities
Parameters
Returns Capabilities

Return the current capability information

See also:
session.getCapabilities()

getGlobalTimeout Session

Int
Parameters
Returns Int

Gets the current value in millis of the global timeout

See also:
val timeout: Int = session.getGlobalTimeout

getName WebElement

String
Parameters
Returns String

gets the name of the element as a string

element.getName

getNameOption WebElement

Option[String]
Parameters
Returns Option[String]

gets the name of the element as an option

element.getNameOption

getSessions Session

List[Sessions]
Parameters
Returns List[Sessions]

Shows a list of existing sessions started by whichever driver is used: e.g. phantom, chrome

session.getSessions()

getSource Session

Option[String]
Parameters
Returns Option[String]

Get the source of the current page

session.getSource

getStatus Session

ServerStatus
Parameters
Returns ServerStatus

Describes the general status of the server

See also:
session.getStatus()

getText WebElement

String
Parameters
Returns String

gets text of element as a string

element.getText

getTextOption WebElement

Option[String]
Parameters
Returns Option[String]

gets text of element as an option

element.getTextOption

getTitle Session

Option[String]
Parameters
Returns Option[String]

Get the title of the current page

session.getTitle

getUrl Session

Option[String]
Parameters
Returns Option[String]

Gets the current url of the page

session.getUrl

getValue TextInput

String
Parameters
Returns String

gets value from TextInput

textInput.getValue

getWindowHandle Session

WindowHandle
Parameters
Returns WindowHandle

Gets the current window handle

See also:
session.getWindowHandle

getWindowHandles Session

List[WindowHandle]
Parameters
Returns List[WindowHandle]

Gets a list of open windows

See also:
session.getWindowHandles

goBack Session

Unit
Parameters
Returns Unit

Operate the browsers go back

session.goBack

goForward Session

Unit
Parameters
Returns Unit

Operate the browsers go forward

session.goForward

isButton WebElement

Boolean
Parameters
Returns Boolean

checks if a WebElement is a button

element.isButton

isDisplayed WebElement

Boolean
Parameters
Returns Boolean

checks if a WebElement is displayed/visible

element.isDisplayed

isEnabled WebElement

Boolean
Parameters
Returns Boolean

checks if a WebElement is enabled

element.isEnabled

isPresent WebElement

Boolean
Parameters
Returns Boolean

checks if a WebElement is enabled and displayed

element.isPresent

isRadio WebElement

Boolean
Parameters
Returns Boolean

checks if a WebElement is a radio

element.isRadio

isSelected WebElement

Boolean
Parameters
Returns Boolean

checks if a WebElement is selected

element.isSelected

isTextArea WebElement

Boolean
Parameters
Returns Boolean

checks if a WebElement is a text area

element.isTextArea

isTextInput WebElement

Boolean
Parameters
Returns Boolean

checks if a WebElement is a text input

element.isTextInput

refresh Session

Unit
Parameters
Returns Unit

Operate the browsers refresh

session.refresh

sendKeys WebElement

String → WebElement
Parameters
  • String text (the string to be typed into the element)
Returns WebElement

sends keystrokes to the WebElement using a string

element.sendKeys("This is cool")

sendKeys WebElement

Keys.Value* → WebElement
Parameters
  • Keys.Value* key (the keys to be typed into the element)
Returns WebElement

sends keystrokes to the WebElement using Keys

element.sendKeys(Keys.TAB, Keys.ENTER)

setAllTimeouts Session

Int
Parameters
  • Int timeout (in millis)

Sets all the timeouts to the supplied value in millis

session.setAllTimeouts(8000)

setAsyncScriptTimeout Session

Int → Unit
Parameters
  • Int milliseconds
Returns Unit

Set a timeout for async script execution

session.setAsyncScriptTimeout(5000)

setGlobalTimeout Session

Int
Parameters
  • Int timeout (in millis, defaults to 5000)

Sets the timeout used in all the functions that perform an internal timeout while waiting for something

See also:
session.setGlobalTimeout(8000)

setImplicitWaitTimeout Session

Int → Unit
Parameters
  • Int milliseconds
Returns Unit

Set a timeout for implicit wait

session.setImplicitWaitTimeout(5000)

setTimeout Session

TimeoutType → Int → Unit
Parameters
  • TimeoutType timeoutType
  • Int milliseconds
Returns Unit

Set a timeout for a specific TimeoutType

See also:
session.setTimeout(TimeoutType.IMPLICIT, 5000)

setValue TextInput

String → WebElement
Parameters
  • String value
Returns WebElement

sets the value of a TextInput

textInput.setValue("some value")

takeScreenshot Session

String → Unit
Parameters
  • String outputFile (defaults to screenshot.png)
Returns Unit

Take a screenshot

session.takeScreenshot("some-file.png")

toButton WebElement

Button
Parameters
Returns Button (throws exception if cannot convert)

converts a WebElement to a Button

element.toButton

toRadio WebElement

Radio
Parameters
Returns Radio (throws exception if cannot convert)

converts a WebElement to a Radio

element.toRadio

toTextArea WebElement

TextArea
Parameters
Returns TextArea (throws exception if cannot convert)

converts a WebElement to a TextArea

element.toTextArea

toTextInput WebElement

TextInput
Parameters
Returns TextInput (throws exception if cannot convert)

converts a WebElement to a TextInput

element.toTextInput

visitUrl Session

String → Session
Parameters
  • String url
Returns Session

Navigate to the supplied url

session.visitUrl("www.google.com")

waitFor Session

T <: Searcher → Condition → Int → WebElement
Parameters
  • T <: Searcher element (takes an element or a By locator)
  • Condition condition (defaults to isVisible)
  • Int timeout (defaults to globalTimeout)
Returns WebElement

Wait for condition to be satisfied

See also:

 // 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
Parameters
  • T <: Searcher element (takes an element or a By locator)
  • Condition condition (defaults to isVisible)
  • Int timeout (defaults to globalTimeout)
Returns WebElement

Wait for condition to be satisfied

See also:

 // 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
Parameters
  • String className
  • Condition condition (defaults to isVisible)
  • Int timeout (defaults to globalTimeout)
Returns WebElement

A shortcut to waitFor using a classname

session.waitForClass("some-classname")

waitForClass WebElement

String → Condition → Int → WebElement
Parameters
  • String className
  • Condition condition (defaults to isVisible)
  • Int timeout (defaults to globalTimeout)
Returns WebElement

A shortcut to waitFor using a classname

element.waitForClass("some-classname")

waitForCss Session

String → Condition → Int → WebElement
Parameters
  • String cssSelector
  • Condition condition (defaults to isVisible)
  • Int timeout (defaults to globalTimeout)
Returns WebElement

A shortcut to waitFor using css selector

session.waitForCss("some-css-selector")

waitForCss WebElement

String → Condition → Int → WebElement
Parameters
  • String cssSelector
  • Condition condition (defaults to isVisible)
  • Int timeout (defaults to globalTimeout)
Returns WebElement

A shortcut to waitFor using css selector

element.waitForCss("some-css-selector")

waitForFunction Session

() => Result → Int → Unit
Parameters
  • () => Result runnable (supply the function here - see example)
  • Int timeout (defaults to globalTimeout)
Returns Unit

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

See also:

 // 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
Parameters
  • () => Result runnable (supply the function here - see example)
  • Int timeout (defaults to globalTimeout)
Returns Unit

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

See also:

 // 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
Parameters
  • String id
  • Condition condition (defaults to isVisible)
  • Int timeout (defaults to globalTimeout)
Returns WebElement

A shortcut to waitFor using an Id

session.waitForId("some-id")

waitForId WebElement

String → Condition → Int → WebElement
Parameters
  • String id
  • Condition condition (defaults to isVisible)
  • Int timeout (defaults to globalTimeout)
Returns WebElement

A shortcut to waitFor using an Id

element.waitForId("some-id")

waitForLinkP Session

String → Condition → Int → WebElement
Parameters
  • String partialLinkText
  • Condition condition (defaults to isVisible)
  • Int timeout (defaults to globalTimeout)
Returns WebElement

A shortcut to waitFor using partial link text

session.waitForLinkP("some partial link text")

waitForLinkP WebElement

String → Condition → Int → WebElement
Parameters
  • String partialLinkText
  • Condition condition (defaults to isVisible)
  • Int timeout (defaults to globalTimeout)
Returns WebElement

A shortcut to waitFor using partial link text

element.waitForLinkP("some partial link text")

waitForName Session

String → Condition → Int → WebElement
Parameters
  • String name
  • Condition condition (defaults to isVisible)
  • Int timeout (defaults to globalTimeout)
Returns WebElement

A shortcut to waitFor using name

session.waitForName("some-name")

waitForName WebElement

String → Condition → Int → WebElement
Parameters
  • String name
  • Condition condition (defaults to isVisible)
  • Int timeout (defaults to globalTimeout)
Returns WebElement

A shortcut to waitFor using name

element.waitForName("some-name")

waitForTag Session

String → Condition → Int → WebElement
Parameters
  • String tagName
  • Condition condition (defaults to isVisible)
  • Int timeout (defaults to globalTimeout)
Returns WebElement

A shortcut to waitFor using a tag name

session.waitForTag("input")

waitForTag WebElement

String → Condition → Int → WebElement
Parameters
  • String tagName
  • Condition condition (defaults to isVisible)
  • Int timeout (defaults to globalTimeout)
Returns WebElement

A shortcut to waitFor using a tag name

element.waitForTag("input")

waitForUrl Session

String
Parameters
  • 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
Parameters
  • String xpath
  • Condition condition (defaults to isVisible)
  • Int timeout (defaults to globalTimeout)
Returns WebElement

A shortcut to waitFor using an xpath

session.waitForXpath("//some/xpath")

waitForXpath WebElement

String → Condition → Int → WebElement
Parameters
  • String xpath
  • Condition condition (defaults to isVisible)
  • Int timeout (defaults to globalTimeout)
Returns WebElement

A shortcut to waitFor using an xpath

element.waitForXpath("//some/xpath")