trait WebBrowser extends AnyRef
Trait that provides a domain specific language (DSL) for writing browser-based tests using Selenium.
To use ScalaTest's Selenium DSL, mix trait WebBrowser
into your test class. This trait provides the DSL in its
entirety except for one missing piece: an implicit org.openqa.selenium.WebDriver
. One way to provide the missing
implicit driver is to declare one as a member of your test class, like this:
import org.scalatest._ import selenium._ import org.openqa.selenium._ import htmlunit._
class BlogSpec extends FlatSpec with Matchers with WebBrowser {
implicit val webDriver: WebDriver = new HtmlUnitDriver
val host = "http://localhost:9000/"
"The blog app home page" should "have the correct title" in { go to (host + "index.html") pageTitle should be ("Awesome Blog") } }
For convenience, however, ScalaTest provides a WebBrowser
subtrait containing an implicit WebDriver
for each
driver provided by Selenium.
Thus a simpler way to use the HtmlUnit
driver, for example, is to extend
ScalaTest's HtmlUnit
trait, like this:
import org.scalatest._ import selenium._
class BlogSpec extends FlatSpec with Matchers with HtmlUnit {
val host = "http://localhost:9000/"
"The blog app home page" should "have the correct title" in { go to (host + "index.html") pageTitle should be ("Awesome Blog") } }
The web driver traits provided by ScalaTest are:
Driver | WebBrowser subtrait |
---|---|
Google Chrome |
Chrome
|
Mozilla Firefox |
Firefox
|
HtmlUnit |
HtmlUnit
|
Microsoft Internet Explorer |
InternetExplorer
|
Apple Safari |
Safari
|
Navigation
You can ask the browser to retrieve a page (go to a URL) like this:
go to "http://www.artima.com"
Note: If you are using the page object pattern, you can also go to a page using the Page
instance, as
illustrated in the section on page objects below.
Once you have retrieved a page, you can fill in and submit forms, query for the values of page elements, and make assertions.
In the following example, selenium will go to http://www.google.com
, fill in the text box with
Cheese!
, press the submit button, and wait for result returned from an AJAX call:
go to "http://www.google.com" click on "q" enter("Cheese!") submit() // Google's search is rendered dynamically with JavaScript. eventually { pageTitle should be ("Cheese! - Google Search") }
In the above example, the "q"
used in “click on "q"
”
can be either the id or name of an element. ScalaTest's Selenium DSL will try to lookup by id first. If it cannot find
any element with an id equal to "q"
, it will then try lookup by name "q"
.
Alternatively, you can be more specific:
click on id("q") // to lookup by id "q" click on name("q") // to lookup by name "q"
In addition to id
and name
, you can use the following approaches to lookup elements, just as you can do with
Selenium's org.openqa.selenium.By
class:
xpath
className
cssSelector
linkText
partialLinkText
tagName
For example, you can select by link text with:
click on linkText("click here!")
If an element is not found via any form of lookup, evaluation will complete abruptly with a TestFailedException
.
Getting and setting input element values
ScalaTest's Selenium DSL provides a clear, simple syntax for accessing and updating the values of input elements such as text fields, radio buttons, checkboxes, selection lists, and the input types introduced in HTML5. If a requested element is not found, or if it is found but is not of the requested type, an exception will immediately result causing the test to fail.
The most common way to access field value is through the value
property, which is supported by the following
input types:
Tag Name | Input Type | Lookup Method |
---|---|---|
input
|
text
|
textField
|
textarea
|
-
|
textArea
|
input
|
password
|
pwdField
|
input
|
email
|
emailField
|
input
|
color
|
colorField
|
input
|
date
|
dateField
|
input
|
datetime
|
dateTimeField
|
input
|
datetime-local
|
dateTimeLocalField
|
input
|
month
|
monthField
|
input
|
number
|
numberField
|
input
|
range
|
rangeField
|
input
|
search
|
searchField
|
input
|
tel
|
telField
|
input
|
time
|
timeField
|
input
|
url
|
urlField
|
input
|
week
|
weekField
|
You can change a input field's value by assigning it via the =
operator, like this:
textField("q").value = "Cheese!"
And you can access a input field's value by simply invoking value
on it:
textField("q").value should be ("Cheese!")
If the text field is empty, value
will return an empty string (""
).
You can use the same syntax with other type of input fields by replacing textField
with Lookup Method
listed in table above,
for example to use text area:
textArea("body").value = "I saw something cool today!" textArea("body").value should be ("I saw something cool today!")
or with a password field:
pwdField("secret").value = "Don't tell anybody!" pwdField("secret").value should be ("Don't tell anybody!")
Alternate Way for Data Entry
An alternate way to enter data into a input fields is to use enter
or pressKeys
.
Although both of enter
and pressKeys
send characters to the active element, pressKeys
can be used on any kind of
element, whereas enter
can only be used on text entry fields, which include:
textField
textArea
pwdField
emailField
searchField
telField
urlField
Another difference is that enter
will clear the text field or area before sending the characters,
effectively replacing any currently existing text with the new text passed to enter
. By contrast,
pressKeys
does not do any clearing—it just appends more characters to any existing text.
You can backup with pressKeys
, however, by sending explicit backspace characters, "\u0008"
.
To use these commands, you must first click on the input field you are interested in to give it the focus. Here's an example:
click on "q" enter("Cheese!")
Here's a (contrived) example of using pressKeys
with backspace to fix a typo:
click on "q" // q is the name or id of a text field or text area enter("Cheesey!") // Oops, meant to say Cheese! pressKeys("\u0008\u0008") // Send two backspaces; now the value is Cheese pressKeys("!") // Send the missing exclamation point; now the value is Cheese!
Radio buttons
Radio buttons work together in groups. For example, you could have a group of radio buttons, like this:
<input type="radio" id="opt1" name="group1" value="Option 1"> Option 1</input> <input type="radio" id="opt2" name="group1" value="Option 2"> Option 2</input> <input type="radio" id="opt3" name="group1" value="Option 3"> Option 3</input>
You can select an option in either of two ways:
radioButtonGroup("group1").value = "Option 2" radioButtonGroup("group1").selection = Some("Option 2")
Likewise, you can read the currently selected value of a group of radio buttons in two ways:
radioButtonGroup("group1").value should be ("Option 2") radioButtonGroup("group1").selection should be (Some("Option 2"))
If the radio button has no selection at all, selection
will return None
whereas value
will throw a TestFailedException
. By using value
, you are indicating you expect a selection, and if there
isn't a selection that should result in a failed test.
If you would like to work with RadioButton
element directly, you can select it by calling radioButton
:
click on radioButton("opt1")
you can check if an option is selected by calling isSelected
:
radioButton("opt1").isSelected should be (true)
to get the value of radio button, you can call value
:
radioButton("opt1").value should be ("Option 1")
Checkboxes
A checkbox in one of two states: selected or cleared. Here's how you select a checkbox:
checkbox("cbx1").select()
And here's how you'd clear one:
checkbox("cbx1").clear()
You can access the current state of a checkbox with isSelected
:
checkbox("cbx1").isSelected should be (true)
Single-selection dropdown lists
Given the following single-selection dropdown list:
<select id="select1"> <option value="option1">Option 1</option> <option value="option2">Option 2</option> <option value="option3">Option 3</option> </select>
You could select Option 2
in either of two ways:
singleSel("select1").value = "option2" singleSel("select1").selection = Some("option2")
To clear the selection, either invoke clear
or set selection
to None
:
singleSel("select1").clear() singleSel("select1").selection = None
You can read the currently selected value of a single-selection list in the same manner as radio buttons:
singleSel("select1").value should be ("option2") singleSel("select1").selection should be (Some("option2"))
If the single-selection list has no selection at all, selection
will return None
whereas value
will throw a TestFailedException
. By using value
, you are indicating you expect a selection, and if there
isn't a selection that should result in a failed test.
Multiple-selection lists
Given the following multiple-selection list:
<select name="select2" multiple="multiple"> <option value="option4">Option 4</option> <option value="option5">Option 5</option> <option value="option6">Option 6</option> </select>
You could select Option 5
and Option 6
like this:
multiSel("select2").values = Seq("option5", "option6")
The previous command would essentially clear all selections first, then select Option 5
and Option 6
.
If instead you want to not clear any existing selection, just additionally select Option 5
and Option 6
,
you can use the +=
operator, like this.
multiSel("select2").values += "option5" multiSel("select2").values += "option6"
To clear a specific option, pass its name to clear
:
multiSel("select2").clear("option5")
To clear all selections, call clearAll
:
multiSel("select2").clearAll()
You can access the current selections with values
, which returns an immutable IndexedSeq[String]
:
multiSel("select2").values should have size 2 multiSel("select2").values(0) should be ("option5") multiSel("select2").values(1) should be ("option6")
Clicking and submitting
You can click on any element with “click on
” as shown previously:
click on "aButton" click on name("aTextField")
If the requested element is not found, click on
will throw an exception, failing the test.
Clicking on a input element will give it the focus. If current focus is in on an input element within a form, you can submit the form by
calling submit
:
submit()
Switching
You can switch to a popup alert bo using the following code:
switch to alertBox
to switch to a frame, you could:
switch to frame(0) // switch by index switch to frame("name") // switch by name
If you have reference to a window handle (can be obtained from calling windowHandle/windowHandles), you can switch to a particular window by:
switch to window(windowHandle)
You can also switch to active element and default content:
switch to activeElement switch to defaultContent
Navigation history
In real web browser, you can press the 'Back' button to go back to previous page. To emulate that action in your test, you can call goBack
:
goBack()
To emulate the 'Forward' button, you can call:
goForward()
And to refresh or reload the current page, you can call:
reloadPage()
Cookies!
To create a new cookie, you'll say:
add cookie ("cookie_name", "cookie_value")
to read a cookie value, you do:
cookie("cookie_name").value should be ("cookie_value") // If value is undefined, throws TFE right then and there. Never returns null.
In addition to the common use of name-value cookie, you can pass these extra fields when creating the cookie, available ways are:
cookie(name: String, value: String) cookie(name: String, value: String, path: String) cookie(name: String, value: String, path: String, expiry: Date) cookie(name: String, value: String, path: String, expiry: Date, domain: String) cookie(name: String, value: String, path: String, expiry: Date, domain: String, secure: Boolean)
and to read those extra fields:
cookie("cookie_name").value // Read cookie's value cookie("cookie_name").path // Read cookie's path cookie("cookie_name").expiry // Read cookie's expiry cookie("cookie_name").domain // Read cookie's domain cookie("cookie_name").isSecure // Read cookie's isSecure flag
In order to delete a cookie, you could use the following code:
delete cookie "cookie_name"
or to delete all cookies in the same domain:-
delete all cookies
To get the underlying Selenium cookie, you can use underlying
:
cookie("cookie_name").underlying.validate() // call the validate() method on underlying Selenium cookie
Other useful element properties
All element types (textField
, textArea
, radioButton
, checkbox
, singleSel
, multiSel
)
support the following useful properties:
Method | Description |
---|---|
location
|
The XY location of the top-left corner of this Element .
|
size
|
The width/height size of this Element .
|
isDisplayed
|
Indicates whether this Element is displayed.
|
isEnabled
|
Indicates whether this Element is enabled.
|
isSelected
|
Indicates whether this Element is selected.
|
tagName
|
The tag name of this element. |
underlying
|
The underlying WebElement wrapped by this Element .
|
attribute(name: String)
|
The attribute value of the given attribute name of this element, wrapped in a Some , or None if no
such attribute exists on this Element .
|
text
|
Returns the visible (i.e., not hidden by CSS) text of this element, including sub-elements, without any leading or trailing whitespace. |
Implicit wait
To set Selenium's implicit wait timeout, you can call the implicitlyWait
method:
implicitlyWait(Span(10, Seconds))
Invoking this method sets the amount of time the driver will wait when searching for an element that is not immediately present. For
more information, see the documentation for method implicitlyWait
.
Page source and current URL
It is possible to get the html source of currently loaded page, using:
pageSource
and if needed, get the current URL of currently loaded page:
currentUrl
Screen capture
You can capture screen using the following code:
val file = capture
By default, the captured image file will be saved in temporary folder (returned by java.io.tmpdir property), with random file name ends with .png extension. You can specify a fixed file name:
capture to "MyScreenShot.png"
or
capture to "MyScreenShot"
Both will result in a same file name MyScreenShot.png
.
You can also change the target folder screenshot file is written to, by saying:
setCaptureDir("/home/your_name/screenshots")
If you want to capture a screenshot when something goes wrong (e.g. test failed), you can use withScreenshot
:
withScreenshot { assert("Gold" == "Silver", "Expected gold, but got silver") }
In case the test code fails, you'll see the screenshot location appended to the error message, for example:
Expected gold but got silver; screenshot capture in /tmp/AbCdEfGhIj.png
Using the page object pattern
If you use the page object pattern, mixing trait Page
into your page classes will allow you to use the go to
syntax with your page objects. Here's an example:
class HomePage extends Page { val url = "http://localhost:9000/index.html" }
val homePage = new HomePage go to homePage
Executing JavaScript
To execute arbitrary JavaScript, for example, to test some JavaScript functions on your page, pass it to executeScript
:
go to (host + "index.html") val result1 = executeScript("return document.title;") result1 should be ("Test Title") val result2 = executeScript("return 'Hello ' + arguments[0]", "ScalaTest") result2 should be ("Hello ScalaTest")
To execute an asynchronous bit of JavaScript, pass it to executeAsyncScript
. You can set the script timeout with setScriptTimeout
:
val script = """ var callback = arguments[arguments.length - 1]; window.setTimeout(function() {callback('Hello ScalaTest')}, 500); """ setScriptTimeout(1 second) val result = executeAsyncScript(script) result should be ("Hello ScalaTest")
Querying for elements
You can query for arbitrary elements via find
and findAll
. The find
method returns the first matching element, wrapped in a Some
,
or None
if no element is found. The findAll
method returns an immutable IndexedSeq
of all matching elements. If no elements match the query, findAll
returns an empty IndexedSeq
. These methods allow you to perform rich queries using for
expressions. Here are some examples:
val ele: Option[Element] = find("q")
val eles: colection.immutable.IndexedSeq[Element] = findAll(className("small")) for (e <- eles; if e.tagName != "input") e should be ('displayed) val textFields = eles filter { tf.isInstanceOf[TextField] }
Cleaning up
To close the current browser window, and exit the driver if the current window was the only one remaining, use close
:
close()
To close all windows, and exit the driver, use quit
:
quit()
Alternate forms
Although statements like “delete all cookies
” fit well with matcher statements
like “title should be ("Cheese!")
”, they do not fit as well
with the simple method call form of assertions. If you prefer, you can avoid operator notation
and instead use alternatives that take the form of plain-old method calls. Here's an example:
goTo("http://www.google.com") clickOn("q") textField("q").value = "Cheese!" submit() // Google's search is rendered dynamically with JavaScript. eventually(assert(pageTitle === "Cheese! - Google Search"))
Here's a table showing the complete list of alternatives:
operator notation | method call |
---|---|
go to (host + "index.html")
|
goTo(host + "index.html")
|
click on "aButton"
|
clickOn("aButton")
|
switch to activeElement
|
switchTo(activeElement)
|
add cookie ("cookie_name", "cookie_value")
|
addCookie("cookie_name", "cookie_value")
|
delete cookie "cookie_name"
|
deleteCookie("cookie_name")
|
delete all cookies
|
deleteAllCookies()
|
capture to "MyScreenShot"
|
captureTo("MyScreenShot")
|
- Alphabetic
- By Inheritance
- WebBrowser
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- final class ActiveElementTarget extends SwitchTarget[Element]
This class supports switching to the currently active element in ScalaTest's Selenium DSL.
This class supports switching to the currently active element in ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class is enables the following syntax:
switch to activeElement ^
- final class AlertTarget extends SwitchTarget[Alert]
This class supports switching to the alert box in ScalaTest's Selenium DSL.
This class supports switching to the alert box in ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class is enables the following syntax:
switch to alertBox ^
- final class Checkbox extends Element
This class is part of ScalaTest's Selenium DSL.
This class is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class enables syntax such as the following:
checkbox("cbx1").select()
- Exceptions thrown
TestFailedExeption
if the passedWebElement
does not represent a checkbox
- case class ClassNameQuery(queryString: String) extends Query with Product with Serializable
A class name query.
A class name query.
This class enables syntax such as the following:
click on className("???") ^
- queryString
the query string for this query.
- final class ColorField extends ValueElement
This class is part of ScalaTest's Selenium DSL.
This class is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class enables syntax such as the following:
colorField("q").value should be ("Cheese!")
- Exceptions thrown
TestFailedExeption
if the passedWebElement
does not represent a color field
- class CookiesNoun extends AnyRef
This class is part of the ScalaTest's Selenium DSL.
This class is part of the ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL. - case class CssSelectorQuery(queryString: String) extends Query with Product with Serializable
A CSS selector query.
A CSS selector query.
This class enables syntax such as the following:
click on cssSelector("???") ^
- queryString
the query string for this query.
- final class DateField extends ValueElement
This class is part of ScalaTest's Selenium DSL.
This class is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class enables syntax such as the following:
dateField("q").value should be ("2003-03-01")
- Exceptions thrown
TestFailedExeption
if the passedWebElement
does not represent a date field
- final class DateTimeField extends ValueElement
This class is part of ScalaTest's Selenium DSL.
This class is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class enables syntax such as the following:
dateTimeField("q").value should be ("2003-03-01T12:13:14")
- Exceptions thrown
TestFailedExeption
if the passedWebElement
does not represent a datetime field
- final class DateTimeLocalField extends ValueElement
This class is part of ScalaTest's Selenium DSL.
This class is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class enables syntax such as the following:
dateTimeLocalField("q").value should be ("2003-03-01T12:13:14")
- Exceptions thrown
TestFailedExeption
if the passedWebElement
does not represent a datetime-local field
- final class DefaultContentTarget extends SwitchTarget[WebDriver]
This class supports switching to the default content in ScalaTest's Selenium DSL.
This class supports switching to the default content in ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class is enables the following syntax:
switch to defaultContent ^
- case class Dimension(width: Int, height: Int) extends Product with Serializable
A dimension containing the width and height of a screen element.
- sealed trait Element extends AnyRef
Wrapper class for a Selenium
WebElement
.Wrapper class for a Selenium
WebElement
.This class provides idiomatic Scala access to the services of an underlying
WebElement
. You can access the wrappedWebElement
via theunderlying
method. - final class EmailField extends ValueElement
This class is part of ScalaTest's Selenium DSL.
This class is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class enables syntax such as the following:
emailField("q").value should be ("foo@bar.com")
- Exceptions thrown
TestFailedExeption
if the passedWebElement
does not represent a email field
- final class FrameElementTarget extends SwitchTarget[WebDriver]
This class supports switching to a frame by element in ScalaTest's Selenium DSL.
This class supports switching to a frame by element in ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL. - final class FrameIndexTarget extends SwitchTarget[WebDriver]
This class supports switching to a frame by index in ScalaTest's Selenium DSL.
This class supports switching to a frame by index in ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class is enables the following syntax:
switch to frame(0) ^
- final class FrameNameOrIdTarget extends SwitchTarget[WebDriver]
This class supports switching to a frame by name or ID in ScalaTest's Selenium DSL.
This class supports switching to a frame by name or ID in ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class is enables the following syntax:
switch to frame("name") ^
- final class FrameWebElementTarget extends SwitchTarget[WebDriver]
This class supports switching to a frame by web element in ScalaTest's Selenium DSL.
This class supports switching to a frame by web element in ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL. - case class IdQuery(queryString: String) extends Query with Product with Serializable
An ID query.
An ID query.
This class enables syntax such as the following:
click on id("q") ^
- queryString
the query string for this query.
- case class LinkTextQuery(queryString: String) extends Query with Product with Serializable
A link text query.
A link text query.
This class enables syntax such as the following:
click on linkText("???") ^
- queryString
the query string for this query.
- final class MonthField extends ValueElement
This class is part of ScalaTest's Selenium DSL.
This class is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class enables syntax such as the following:
monthField("q").value should be ("2003-04")
- Exceptions thrown
TestFailedExeption
if the passedWebElement
does not represent a month field
- class MultiSel extends Element
This class is part of ScalaTest's Selenium DSL.
This class is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class enables syntax such as the following:
multiSel("select2").clear("option5")
- Exceptions thrown
TestFailedExeption
if the passedWebElement
does not represent a multiple selection list
- class MultiSelOptionSeq extends IndexedSeq[String]
This class is part of ScalaTest's Selenium DSL.
This class is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class enables syntax such as the following:
multiSel("select2").values += "option5" ^
Instances of this class are returned from the
values
method ofMultiSel
.MultiSelOptionSeq
is an immutableIndexedSeq[String]
that wraps an underlying immutableIndexedSeq[String]
and adds two methods,+
and-
, to facilitate the+=
syntax for setting additional options of theMultiSel
. The Scala compiler will rewrite:multiSel("select2").values += "option5"
To:
multiSel("select2").values = multiSel("select2").values + "option5"
Thus, first a new
MultiSelOptionSeq
is created by invoking the+
method on theMultiSelOptionSeq
returned byvalues
, and that result is passed to thevalues_=
method.For symmetry, this class also offers a
-
method, which can be used to deselect an option, like this:multiSel("select2").values -= "option5" ^
- case class NameQuery(queryString: String) extends Query with Product with Serializable
A name query.
A name query.
This class enables syntax such as the following:
click on name("q") ^
- queryString
the query string for this query.
- final class NumberField extends ValueElement
This class is part of ScalaTest's Selenium DSL.
This class is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class enables syntax such as the following:
numberField("q").value should be ("1.3")
- Exceptions thrown
TestFailedExeption
if the passedWebElement
does not represent a number field
- case class PartialLinkTextQuery(queryString: String) extends Query with Product with Serializable
A partial link text query.
A partial link text query.
This class enables syntax such as the following:
click on partialLinkText("???") ^
- queryString
the query string for this query.
- final class PasswordField extends Element
This class is part of ScalaTest's Selenium DSL.
This class is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class enables syntax such as the following:
pwdField("q").value should be ("Cheese!")
- Exceptions thrown
TestFailedExeption
if the passedWebElement
does not represent a password field
- case class Point(x: Int, y: Int) extends Product with Serializable
A point containing an XY screen location.
- sealed trait Query extends Product with Serializable
This trait is part of ScalaTest's Selenium DSL.
This trait is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.Subclasses of this trait define different ways of querying for elements, enabling syntax such as the following:
click on id("q") ^
- final class RadioButton extends Element
This class is part of ScalaTest's Selenium DSL.
This class is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class enables syntax such as the following:
radioButton(id("opt1")).value should be ("Option 1!")
- Exceptions thrown
TestFailedExeption
if the passedWebElement
does not represent a text area
- final class RadioButtonGroup extends AnyRef
This class is part of ScalaTest's Selenium DSL.
This class is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class enables syntax such as the following:
radioButtonGroup("group1").value should be ("Option 2")
- Exceptions thrown
TestFailedExeption
if no radio button with the passedgroupName
are found
- final class RangeField extends ValueElement
This class is part of ScalaTest's Selenium DSL.
This class is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class enables syntax such as the following:
rangeField("q").value should be ("1.3")
- Exceptions thrown
TestFailedExeption
if the passedWebElement
does not represent a range field
- final class SearchField extends ValueElement
This class is part of ScalaTest's Selenium DSL.
This class is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class enables syntax such as the following:
searchField("q").value should be ("google")
- Exceptions thrown
TestFailedExeption
if the passedWebElement
does not represent a search field
- class SingleSel extends Element
This class is part of ScalaTest's Selenium DSL.
This class is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class enables syntax such as the following:
singleSel.clear()
- Exceptions thrown
TestFailedExeption
if the passedWebElement
does not represent a single selection list
- sealed abstract class SwitchTarget[T] extends AnyRef
This sealed abstract class supports switching in ScalaTest's Selenium DSL.
This sealed abstract class supports switching in ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.One subclass of
SwitchTarget
exists for each kind of target that can be switched to: active element, alert box, default content, frame (indentified by index, name or id, or enclosed element), and window. - case class TagNameQuery(queryString: String) extends Query with Product with Serializable
A tag name query.
A tag name query.
This class enables syntax such as the following:
click on tagName("???") ^
- queryString
the query string for this query.
- final class TelField extends ValueElement
This class is part of ScalaTest's Selenium DSL.
This class is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class enables syntax such as the following:
telField("q").value should be ("911-911-9191")
- Exceptions thrown
TestFailedExeption
if the passedWebElement
does not represent a tel field
- final class TextArea extends Element
This class is part of ScalaTest's Selenium DSL.
This class is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class enables syntax such as the following:
textArea("q").value should be ("Cheese!")
- Exceptions thrown
TestFailedExeption
if the passedWebElement
does not represent a text area
- final class TextField extends Element
This class is part of ScalaTest's Selenium DSL.
This class is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class enables syntax such as the following:
textField("q").value should be ("Cheese!")
- Exceptions thrown
TestFailedExeption
if the passedWebElement
does not represent a text field
- final class TimeField extends ValueElement
This class is part of ScalaTest's Selenium DSL.
This class is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class enables syntax such as the following:
timeField("q").value should be ("12:13:14")
- Exceptions thrown
TestFailedExeption
if the passedWebElement
does not represent a time field
- final class UrlField extends ValueElement
This class is part of ScalaTest's Selenium DSL.
This class is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class enables syntax such as the following:
urlField("q").value should be ("http://google.com")
- Exceptions thrown
TestFailedExeption
if the passedWebElement
does not represent a url field
- trait ValueElement extends Element
- final class WeekField extends ValueElement
This class is part of ScalaTest's Selenium DSL.
This class is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class enables syntax such as the following:
weekField("q").value should be ("1996-W16")
- Exceptions thrown
TestFailedExeption
if the passedWebElement
does not represent a week field
- final class WindowTarget extends SwitchTarget[WebDriver]
This class supports switching to a window by name or handle in ScalaTest's Selenium DSL.
This class supports switching to a window by name or handle in ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class is enables the following syntax:
switch to window(windowHandle) ^
- final class WrappedCookie extends AnyRef
Wrapper class for a Selenium
Cookie
.Wrapper class for a Selenium
Cookie
.This class provides idiomatic Scala access to the services of an underlying
Cookie
. You can access the wrappedCookie
via theunderlying
method. - case class XPathQuery(queryString: String) extends Query with Product with Serializable
An XPath query.
An XPath query.
This class enables syntax such as the following:
click on xpath("???") ^
- queryString
the query string for this query.
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- val activeElement: ActiveElementTarget
This value supports switching to the currently active element in ScalaTest's Selenium DSL.
This value supports switching to the currently active element in ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class is enables the following syntax:
switch to activeElement ^
- def addCookie(name: String, value: String, path: String = "/", expiry: Date = null, domain: String = null, secure: Boolean = false)(implicit driver: WebDriver): Unit
Add cookie in the web browser.
Add cookie in the web browser. If the cookie's domain name is left blank (default), it is assumed that the cookie is meant for the domain of the current document.
- name
cookie's name
- value
cookie's value
- path
cookie's path
- expiry
cookie's expiry data
- domain
cookie's domain name
- secure
whether this cookie is secured.
- driver
the
WebDriver
with which to drive the browser
- val alertBox: AlertTarget
This value supports switching to the alert box in ScalaTest's Selenium DSL.
This value supports switching to the alert box in ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class is enables the following syntax:
switch to alertBox ^
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def captureTo(fileName: String)(implicit driver: WebDriver): Unit
Capture screenshot and save it as the specified name (if file name does not end with .png, it will be extended automatically) in capture directory, which by default is system property's java.io.tmpdir.
Capture screenshot and save it as the specified name (if file name does not end with .png, it will be extended automatically) in capture directory, which by default is system property's java.io.tmpdir. You can change capture directory by calling
setCaptureDir
- fileName
screenshot file name, if does not end with .png, it will be extended automatically
- def checkbox(queryString: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): Checkbox
Finds and returns the first
Checkbox
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aCheckbox
.Finds and returns the first
Checkbox
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aCheckbox
.- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser- returns
the
Checkbox
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aCheckbox
- def checkbox(query: Query)(implicit driver: WebDriver, pos: Position): Checkbox
Finds and returns the first
Checkbox
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aCheckbox
.Finds and returns the first
Checkbox
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aCheckbox
.- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser- returns
the
Checkbox
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aCheckbox
- def className(className: String): ClassNameQuery
Returns a class name query.
Returns a class name query.
This method enables syntax such as the following:
click on className("???") ^
- def clickOn(element: Element): Unit
Click on the specified
Element
Click on the specified
Element
- element
the
Element
to click on
- def clickOn(queryString: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): Unit
Click on the first
Element
selected by the specified string ID or nameClick on the first
Element
selected by the specified string ID or name- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser
- def clickOn(query: Query)(implicit driver: WebDriver): Unit
Click on the first
Element
selected by the specifiedQuery
Click on the first
Element
selected by the specifiedQuery
- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser
- def clickOn(element: WebElement): Unit
Click on the specified
WebElement
Click on the specified
WebElement
- element
the
WebElement
to click on
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def close()(implicit driver: WebDriver): Unit
Closes the current browser window, and exits the driver if the current window was the only one remaining.
Closes the current browser window, and exits the driver if the current window was the only one remaining.
- driver
the
WebDriver
with which to drive the browser
- def colorField(queryString: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): ColorField
Finds and returns the first
ColorField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aColorField
.Finds and returns the first
ColorField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aColorField
.- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser- returns
the
ColorField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aColorField
- def colorField(query: Query)(implicit driver: WebDriver, pos: Position): ColorField
Finds and returns the first
ColorField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aColorField
.Finds and returns the first
ColorField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aColorField
.- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser- returns
the
ColorField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aColorField
- def cookie(name: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): WrappedCookie
Get a saved cookie from web browser, throws TestFailedException if the cookie does not exist.
Get a saved cookie from web browser, throws TestFailedException if the cookie does not exist.
- name
cookie's name
- returns
a WrappedCookie instance
- val cookies: CookiesNoun
This field supports cookie deletion in ScalaTest's Selenium DSL.
This field supports cookie deletion in ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This field enables the following syntax:
delete all cookies ^
- def cssSelector(cssSelector: String): CssSelectorQuery
Returns a CSS selector query.
Returns a CSS selector query.
This method enables syntax such as the following:
click on cssSelector("???") ^
- def currentUrl(implicit driver: WebDriver): String
Returns the URL of the current page.
Returns the URL of the current page.
This method invokes
getCurrentUrl
on the passedWebDriver
and returns the result.- driver
the
WebDriver
with which to drive the browser- returns
the URL of the current page
- def dateField(queryString: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): DateField
Finds and returns the first
DateField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aDateField
.Finds and returns the first
DateField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aDateField
.- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser- returns
the
DateField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aDateField
- def dateField(query: Query)(implicit driver: WebDriver, pos: Position): DateField
Finds and returns the first
DateField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aDateField
.Finds and returns the first
DateField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aDateField
.- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser- returns
the
DateField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aDateField
- def dateTimeField(queryString: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): DateTimeField
Finds and returns the first
DateTimeField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aDateTimeField
.Finds and returns the first
DateTimeField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aDateTimeField
.- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser- returns
the
DateTimeField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aDateTimeField
- def dateTimeField(query: Query)(implicit driver: WebDriver, pos: Position): DateTimeField
Finds and returns the first
DateTimeField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aDateTimeField
.Finds and returns the first
DateTimeField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aDateTimeField
.- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser- returns
the
DateTimeField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aDateTimeField
- def dateTimeLocalField(queryString: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): DateTimeLocalField
Finds and returns the first
DateTimeLocalField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aDateTimeLocalField
.Finds and returns the first
DateTimeLocalField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aDateTimeLocalField
.- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser- returns
the
DateTimeLocalField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aDateTimeLocalField
- def dateTimeLocalField(query: Query)(implicit driver: WebDriver, pos: Position): DateTimeLocalField
Finds and returns the first
DateTimeLocalField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aDateTimeLocalField
.Finds and returns the first
DateTimeLocalField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aDateTimeLocalField
.- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser- returns
the
DateTimeLocalField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aDateTimeLocalField
- val defaultContent: DefaultContentTarget
This value supports switching to the default content in ScalaTest's Selenium DSL.
This value supports switching to the default content in ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class is enables the following syntax:
switch to defaultContent ^
- def deleteAllCookies()(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): Unit
Delete all cookies in the current domain from web browser.
Delete all cookies in the current domain from web browser.
- driver
the
WebDriver
with which to drive the browser
- def deleteCookie(name: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): Unit
Delete cookie with the specified name from web browser, throws TestFailedException if the specified cookie does not exists.
Delete cookie with the specified name from web browser, throws TestFailedException if the specified cookie does not exists.
- name
cookie's name
- driver
the
WebDriver
with which to drive the browser
- def emailField(queryString: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): EmailField
Finds and returns the first
EmailField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aEmailField
.Finds and returns the first
EmailField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aEmailField
.- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser- returns
the
EmailField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aEmailField
- def emailField(query: Query)(implicit driver: WebDriver, pos: Position): EmailField
Finds and returns the first
EmailField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aEmailField
.Finds and returns the first
EmailField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aEmailField
.- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser- returns
the
EmailField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aEmailField
- def enter(value: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): Unit
Clears the current active
TextField
orTextArea
, and presses the passed keys.Clears the current active
TextField
orTextArea
, and presses the passed keys. ThrowsTestFailedException
if current active is notTextField
orTextArea
.- value
keys to press in current active
TextField
orTextArea
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def executeAsyncScript(script: String, args: AnyRef*)(implicit driver: WebDriver): AnyRef
Executes an asynchronous piece of JavaScript in the context of the currently selected frame or window.
Executes an asynchronous piece of JavaScript in the context of the currently selected frame or window. Unlike executing synchronous JavaScript, scripts executed with this method must explicitly signal they are finished by invoking the provided callback. This callback is always injected into the executed function as the last argument.
The first argument passed to the callback function will be used as the script's result. This value will be handled as follows:
- For an HTML element, this method returns a WebElement
- For a number, a Long is returned
- For a boolean, a Boolean is returned
- For all other cases, a String is returned
- For an array, return a List<Object> with each object following the rules above. We support nested lists
- Unless the value is null or there is no return value, in which null is returned
Script arguments must be a number, boolean, String, WebElement, or a List of any combination of these. An exception will be thrown if the arguments do not meet these criteria. The arguments will be made available to the JavaScript via the "arguments" variable. (Note that although this behavior is specified by Selenium's JavascriptExecutor Javadoc, it may still be possible for the underlying
JavascriptExecutor
implementation to return an objects of other types. For example,HtmlUnit
has been observed to return ajava.util.Map
for a Javascript object.)- script
the JavaScript to execute
- args
the arguments to the script, may be empty
- returns
One of Boolean, Long, String, List, WebElement, or null (following Selenium's JavascriptExecutor Javadoc)
- def executeScript[T](script: String, args: AnyRef*)(implicit driver: WebDriver): AnyRef
Executes JavaScript in the context of the currently selected frame or window.
Executes JavaScript in the context of the currently selected frame or window. The script fragment provided will be executed as the body of an anonymous function.
Within the script, you can use
document
to refer to the current document. Local variables will not be available once the script has finished executing, but global variables will.To return a value (e.g. if the script contains a return statement), then the following steps will be taken:
- For an HTML element, this method returns a WebElement
- For a decimal, a Double is returned
- For a non-decimal number, a Long is returned
- For a boolean, a Boolean is returned
- For all other cases, a String is returned
- For an array, return a List<Object> with each object following the rules above. We support nested lists
- Unless the value is null or there is no return value, in which null is returned
Script arguments must be a number, boolean, String, WebElement, or a List of any combination of these. An exception will be thrown if the arguments do not meet these criteria. The arguments will be made available to the JavaScript via the "arguments" variable. (Note that although this behavior is specified by Selenium's JavascriptExecutor Javadoc, it may still be possible for the underlying
JavascriptExecutor
implementation to return an objects of other types. For example,HtmlUnit
has been observed to return ajava.util.Map
for a Javascript object.)- script
the JavaScript to execute
- args
the arguments to the script, may be empty
- returns
One of Boolean, Long, String, List or WebElement. Or null (following Selenium's JavascriptExecutor Javadoc)
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def find(queryString: String)(implicit driver: WebDriver): Option[Element]
Finds and returns the first element selected by the specified string ID or name, wrapped in a
Some
, orNone
if no element is selected.Finds and returns the first element selected by the specified string ID or name, wrapped in a
Some
, orNone
if no element is selected. YYYThis method will try to lookup by id first. If it cannot find any element with an id equal to the specified
queryString
, it will then try lookup by name.The class of the
Element
returned will be a subtype ofElement
if appropriate. For example, if the query selects a text field, the class of the returnedElement
will beTextField
.- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser- returns
the
Element
selected by this query, wrapped in aSome
, orNone
if noElement
is selected
- def find(query: Query)(implicit driver: WebDriver): Option[Element]
Finds and returns the first element selected by the specified
Query
, wrapped in aSome
, orNone
if no element is selected.Finds and returns the first element selected by the specified
Query
, wrapped in aSome
, orNone
if no element is selected.The class of the
Element
returned will be a subtype ofElement
if appropriate. For example, if the query selects a text field, the class of the returnedElement
will beTextField
.- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser- returns
the
Element
selected by this query, wrapped in aSome
, orNone
if noElement
is selected
- def findAll(queryString: String)(implicit driver: WebDriver): Iterator[Element]
Returns an
Iterator
over allElement
s selected by the specified string ID or nameReturns an
Iterator
over allElement
s selected by the specified string ID or nameThis method will try to lookup by id first. If it cannot find any element with an id equal to the specified
queryString
, it will then try lookup by name.The class of the
Element
returned will be a subtype ofElement
if appropriate. For example, if the query selects a text field, the class of the returnedElement
will beTextField
.- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser- returns
the
Iterator
over allElement
s selected by this query
- def findAll(query: Query)(implicit driver: WebDriver): Iterator[Element]
Returns an
Iterator
over allElement
s selected by this query.Returns an
Iterator
over allElement
s selected by this query.The class of the
Element
s produced by the returnedIterator
will be a subtypes ofElement
if appropriate. For example, if anElement
representing a text field is returned by theIterator
, the class of the returnedElement
will beTextField
.If no
Elements
are selected by this query, this method will return an emptyIterator
will be returned.- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser- returns
the
Iterator
over allElement
s selected by this query
- def frame(query: Query)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): FrameWebElementTarget
This method supports switching to a frame by
Query
in ScalaTest's Selenium DSL.This method supports switching to a frame by
Query
in ScalaTest's Selenium DSL. Please see the documentation forWebBrowser
for an overview of the Selenium DSL.- query
Query
used to selectWebElement
which is contained in the frame to switch to- returns
a FrameWebElementTarget instance
- def frame(element: Element): FrameElementTarget
This method supports switching to a frame by element in ScalaTest's Selenium DSL.
This method supports switching to a frame by element in ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.- element
Element
which is contained in the frame to switch to- returns
a FrameElementTarget instance
- def frame(element: WebElement): FrameWebElementTarget
This method supports switching to a frame by web element in ScalaTest's Selenium DSL.
This method supports switching to a frame by web element in ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.- element
WebElement
which is contained in the frame to switch to- returns
a FrameWebElementTarget instance
- def frame(nameOrId: String): FrameNameOrIdTarget
This method supports switching to a frame by name or ID in ScalaTest's Selenium DSL.
This method supports switching to a frame by name or ID in ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class is enables the following syntax:
switch to frame("name") ^
- nameOrId
name or ID of the frame to switch to
- returns
a FrameNameOrIdTarget instance
- def frame(index: Int): FrameIndexTarget
This method supports switching to a frame by index in ScalaTest's Selenium DSL.
This method supports switching to a frame by index in ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class is enables the following syntax:
switch to frame(0) ^
- index
the index of frame to switch to
- returns
a FrameIndexTarget instance
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def goBack()(implicit driver: WebDriver): Unit
Go back to previous page.
Go back to previous page.
- driver
the
WebDriver
with which to drive the browser
- def goForward()(implicit driver: WebDriver): Unit
Go forward to next page.
Go forward to next page.
- driver
the
WebDriver
with which to drive the browser
- def goTo(page: Page)(implicit driver: WebDriver): Unit
Sends the browser to the URL contained in the passed
Page
object.Sends the browser to the URL contained in the passed
Page
object.Here's an example:
goTo(homePage)
- page
the
Page
object containing the URL to which to send the browser- driver
the
WebDriver
with which to drive the browser
- def goTo(url: String)(implicit driver: WebDriver): Unit
Sends the browser to the passed URL.
Sends the browser to the passed URL.
Here's an example:
goTo("http://www.artima.com")
- url
the URL to which to send the browser
- driver
the
WebDriver
with which to drive the browser
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def id(elementId: String): IdQuery
Returns an ID query.
Returns an ID query.
This method enables syntax such as the following:
click on id("q") ^
- def implicitlyWait(timeout: Span)(implicit driver: WebDriver): Unit
Sets the amount of time the driver should wait when searching for an element that is not immediately present.
Sets the amount of time the driver should wait when searching for an element that is not immediately present.
When searching for requested elements, Selenium will poll the page until the requested element (or at least one of multiple requested elements) is found or this "implicit wait" timeout has expired. If the timeout expires, Selenium will throw
NoSuchElementException
, which ScalaTest's Selenium DSL will wrap in aTestFailedException
.You can alternatively set this timeout to zero and use ScalaTest's
eventually
construct.This method invokes
manage.timeouts.implicitlyWait
on the passedWebDriver
. See the documentation of Selenium'sWebDriver#Timeouts
interface for more information.- timeout
the time span to implicitly wait
- driver
the
WebDriver
on which to set the implicit wait
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isScreenshotSupported(implicit driver: WebDriver): Boolean
Check if screenshot is supported
Check if screenshot is supported
- driver
the
WebDriver
with which to drive the browser- returns
true if screenshot is supported, false otherwise
- def linkText(linkText: String): LinkTextQuery
Returns a link text query.
Returns a link text query.
This method enables syntax such as the following:
click on linkText("???") ^
- def monthField(queryString: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): MonthField
Finds and returns the first
MonthField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aMonthField
.Finds and returns the first
MonthField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aMonthField
.- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser- returns
the
MonthField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aMonthField
- def monthField(query: Query)(implicit driver: WebDriver, pos: Position): MonthField
Finds and returns the first
MonthField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aMonthField
.Finds and returns the first
MonthField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aMonthField
.- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser- returns
the
MonthField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aMonthField
- def multiSel(queryString: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): MultiSel
Finds and returns the first
MultiSel
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aMultiSel
.Finds and returns the first
MultiSel
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aMultiSel
.- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser- returns
the
MultiSel
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aMultiSel
- def multiSel(query: Query)(implicit driver: WebDriver, pos: Position): MultiSel
Finds and returns the first
MultiSel
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aMultiSel
.Finds and returns the first
MultiSel
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aMultiSel
.- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser- returns
the
MultiSel
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aMultiSel
- def name(elementName: String): NameQuery
Returns a name query.
Returns a name query.
This method enables syntax such as the following:
click on name("q") ^
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def numberField(queryString: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): NumberField
Finds and returns the first
NumberField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aNumberField
.Finds and returns the first
NumberField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aNumberField
.- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser- returns
the
NumberField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aNumberField
- def numberField(query: Query)(implicit driver: WebDriver, pos: Position): NumberField
Finds and returns the first
NumberField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aNumberField
.Finds and returns the first
NumberField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aNumberField
.- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser- returns
the
NumberField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aNumberField
- def pageSource(implicit driver: WebDriver): String
Returns the source of the current page.
Returns the source of the current page.
This method invokes
getPageSource
on the passedWebDriver
and returns the result.- driver
the
WebDriver
with which to drive the browser- returns
the source of the current page
- def pageTitle(implicit driver: WebDriver): String
Returns the title of the current page, or the empty string if the current page has no title.
Returns the title of the current page, or the empty string if the current page has no title.
- driver
the
WebDriver
with which to drive the browser- returns
the current page's title, or the empty string if the current page has no title
- def partialLinkText(partialLinkText: String): PartialLinkTextQuery
Returns a partial link text query.
Returns a partial link text query.
This method enables syntax such as the following:
click on partialLinkText("???") ^
- def pressKeys(value: String)(implicit driver: WebDriver): Unit
Press the passed keys to current active element.
Press the passed keys to current active element.
- value
keys to press in current active element
- def pwdField(queryString: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): PasswordField
Finds and returns the first
PasswordField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aPasswordField
.Finds and returns the first
PasswordField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aPasswordField
.- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser- returns
the
PasswordField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aPasswordField
- def pwdField(query: Query)(implicit driver: WebDriver, pos: Position): PasswordField
Finds and returns the first
PasswordField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aPasswordField
.Finds and returns the first
PasswordField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aPasswordField
.- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser- returns
the
PasswordField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aPasswordField
- def quit()(implicit driver: WebDriver): Unit
Close all windows, and exit the driver.
Close all windows, and exit the driver.
- driver
the
WebDriver
on which to quit.
- def radioButton(queryString: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): RadioButton
Finds and returns the first
RadioButton
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aRadioButton
.Finds and returns the first
RadioButton
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aRadioButton
.- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser- returns
the
RadioButton
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aRadioButton
- def radioButton(query: Query)(implicit driver: WebDriver, pos: Position): RadioButton
Finds and returns the first
RadioButton
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aRadioButton
.Finds and returns the first
RadioButton
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aRadioButton
.- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser- returns
the
RadioButton
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aRadioButton
- def radioButtonGroup(groupName: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): RadioButtonGroup
Finds and returns
RadioButtonGroup
selected by the specified group name, throwsTestFailedException
if no element with the specified group name is found, or found any element with the specified group name but not aRadioButton
Finds and returns
RadioButtonGroup
selected by the specified group name, throwsTestFailedException
if no element with the specified group name is found, or found any element with the specified group name but not aRadioButton
- groupName
the group name with which to search
- driver
the
WebDriver
with which to drive the browser- returns
the
RadioButtonGroup
selected by this query
- Exceptions thrown
TestFailedException
if no element with the specified group name is found, or found any element with the specified group name but not aRadioButton
- def rangeField(queryString: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): RangeField
Finds and returns the first
RangeField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aRangeField
.Finds and returns the first
RangeField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aRangeField
.- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser- returns
the
RangeField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aRangeField
- def rangeField(query: Query)(implicit driver: WebDriver, pos: Position): RangeField
Finds and returns the first
RangeField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aRangeField
.Finds and returns the first
RangeField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aRangeField
.- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser- returns
the
RangeField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aRangeField
- def reloadPage()(implicit driver: WebDriver): Unit
Reload the current page.
Reload the current page.
- driver
the
WebDriver
with which to drive the browser
- def searchField(queryString: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): SearchField
Finds and returns the first
SearchField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aSearchField
.Finds and returns the first
SearchField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aSearchField
.- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser- returns
the
SearchField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aSearchField
- def searchField(query: Query)(implicit driver: WebDriver, pos: Position): SearchField
Finds and returns the first
SearchField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aSearchField
.Finds and returns the first
SearchField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aSearchField
.- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser- returns
the
SearchField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aSearchField
- def setCaptureDir(targetDirPath: String): Unit
Set capture directory.
Set capture directory.
- targetDirPath
the path of capture directory
- def setScriptTimeout(timeout: Span)(implicit driver: WebDriver): Unit
Sets the amount of time to wait for an asynchronous script to finish execution before throwing an exception.
Sets the amount of time to wait for an asynchronous script to finish execution before throwing an exception.
- timeout
the amount of time to wait for an asynchronous script to finish execution before throwing exception
- def singleSel(queryString: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): SingleSel
Finds and returns the first
SingleSel
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aSingleSel
.Finds and returns the first
SingleSel
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aSingleSel
.- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser- returns
the
SingleSel
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aSingleSel
- def singleSel(query: Query)(implicit driver: WebDriver, pos: Position): SingleSel
Finds and returns the first
SingleSel
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aSingleSel
.Finds and returns the first
SingleSel
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aSingleSel
.- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser- returns
the
SingleSel
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aSingleSel
- def submit()(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): Unit
Submit the form where current active element belongs to, and throws TestFailedException if current active element is not in a form or underlying WebDriver encounters problem when submitting the form.
Submit the form where current active element belongs to, and throws TestFailedException if current active element is not in a form or underlying WebDriver encounters problem when submitting the form. If this causes the current page to change, this call will block until the new page is loaded.
- driver
the
WebDriver
with which to drive the browser
- Exceptions thrown
TestFailedException
if current active element is not in a form or underlying WebDriver encounters problem when submitting the form.
- def switchTo[T](target: SwitchTarget[T])(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): T
Switch to the specified
SwitchTarget
Switch to the specified
SwitchTarget
- target
the
SwitchTarget
to switch to- driver
the
WebDriver
with which to drive the browser- returns
instance of specified
SwitchTarget
's type parameter
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def tagName(tagName: String): TagNameQuery
Returns a tag name query.
Returns a tag name query.
This method enables syntax such as the following:
click on tagName("???") ^
- def telField(queryString: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): TelField
Finds and returns the first
TelField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aTelField
.Finds and returns the first
TelField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aTelField
.- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser- returns
the
TelField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aTelField
- def telField(query: Query)(implicit driver: WebDriver, pos: Position): TelField
Finds and returns the first
TelField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aTelField
.Finds and returns the first
TelField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aTelField
.- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser- returns
the
TelField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aTelField
- def textArea(queryString: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): TextArea
Finds and returns the first
TextArea
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aTextArea
.Finds and returns the first
TextArea
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aTextArea
.- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser- returns
the
TextArea
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aTextArea
- def textArea(query: Query)(implicit driver: WebDriver, pos: Position): TextArea
Finds and returns the first
TextArea
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aTextArea
.Finds and returns the first
TextArea
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aTextArea
.- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser- returns
the
TextArea
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aTextArea
- def textField(queryString: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): TextField
Finds and returns the first
TextField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aTextField
.Finds and returns the first
TextField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aTextField
.- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser- returns
the
TextField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aTextField
- def textField(query: Query)(implicit driver: WebDriver, pos: Position): TextField
Finds and returns the first
TextField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aTextField
.Finds and returns the first
TextField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aTextField
.- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser- returns
the
TextField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aTextField
- def timeField(queryString: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): TimeField
Finds and returns the first
TimeField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aTimeField
.Finds and returns the first
TimeField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aTimeField
.- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser- returns
the
TimeField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aTimeField
- def timeField(query: Query)(implicit driver: WebDriver, pos: Position): TimeField
Finds and returns the first
TimeField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aTimeField
.Finds and returns the first
TimeField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aTimeField
.- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser- returns
the
TimeField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aTimeField
- def toString(): String
- Definition Classes
- AnyRef → Any
- def urlField(queryString: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): UrlField
Finds and returns the first
UrlField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aUrlField
.Finds and returns the first
UrlField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aUrlField
.- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser- returns
the
UrlField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aUrlField
- def urlField(query: Query)(implicit driver: WebDriver, pos: Position): UrlField
Finds and returns the first
UrlField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aUrlField
.Finds and returns the first
UrlField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aUrlField
.- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser- returns
the
UrlField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aUrlField
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def weekField(queryString: String)(implicit driver: WebDriver, pos: Position = implicitly[source.Position]): WeekField
Finds and returns the first
WeekField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aWeekField
.Finds and returns the first
WeekField
selected by the specified string ID or name, throwsTestFailedException
if element not found or the found element is not aWeekField
.- queryString
the string with which to search, first by ID then by name
- driver
the
WebDriver
with which to drive the browser- returns
the
WeekField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aWeekField
- def weekField(query: Query)(implicit driver: WebDriver, pos: Position): WeekField
Finds and returns the first
WeekField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aWeekField
.Finds and returns the first
WeekField
selected by the specifiedQuery
, throwsTestFailedException
if element not found or the found element is not aWeekField
.- query
the
Query
with which to search- driver
the
WebDriver
with which to drive the browser- returns
the
WeekField
selected by this query
- Exceptions thrown
TestFailedException
if element not found or found element is not aWeekField
- def window(nameOrHandle: String): WindowTarget
This class supports switching to a window by name or handle in ScalaTest's Selenium DSL.
This class supports switching to a window by name or handle in ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This class is enables the following syntax:
switch to window(windowHandle) ^
- nameOrHandle
name or window handle of the window to switch to
- returns
a WindowTarget instance
- def windowHandle(implicit driver: WebDriver): String
Get an opaque handle to current active window that uniquely identifies it within the implicit driver instance.
Get an opaque handle to current active window that uniquely identifies it within the implicit driver instance.
- driver
the
WebDriver
with which to drive the browser
- def windowHandles(implicit driver: WebDriver): Set[String]
Get a set of window handles which can be used to iterate over all open windows
Get a set of window handles which can be used to iterate over all open windows
- driver
the
WebDriver
with which to drive the browser
- def withScreenshot[T](fun: => T)(implicit driver: WebDriver): T
Execute the given function, if
ModifiableMessage
exception is thrown from the given function, a screenshot will be captured automatically into capture directory, which by default is system property's java.io.tmpdir.Execute the given function, if
ModifiableMessage
exception is thrown from the given function, a screenshot will be captured automatically into capture directory, which by default is system property's java.io.tmpdir. You can change capture directory by callingsetCaptureDir
- fun
function to execute
- returns
the value returned by
fun
- def xpath(xpath: String): XPathQuery
Returns an XPath query.
Returns an XPath query.
This method enables syntax such as the following:
click on xpath("???") ^
- object add
This object is part of ScalaTest's Selenium DSL.
This object is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This object enables syntax such as the following:
add cookie("aName", "aValue") ^
- object capture
This object is part of ScalaTest's Selenium DSL.
This object is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This object enables syntax such as the following:
capture ^
capture to "MyScreenshot.png" ^ - object click
This object is part of ScalaTest's Selenium DSL.
This object is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This object enables syntax such as the following:
click on "aButton" ^
- object delete
This object is part of ScalaTest's Selenium DSL.
This object is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This object enables syntax such as the following:
delete cookie "aName" ^
delete all cookies ^ - object go
This object is part of ScalaTest's Selenium DSL.
This object is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This object enables syntax such as the following:
go to "http://www.artima.com" ^
- object switch
This object is part of ScalaTest's Selenium DSL.
This object is part of ScalaTest's Selenium DSL. Please see the documentation for
WebBrowser
for an overview of the Selenium DSL.This object enables syntax such as the following:
switch to alertBox ^