acceptAlert()
Accepts the currently displayed alert dialog. Usually, this is
equivalent to clicking the 'OK' button in the dialog.
addCookie(
name,
value,
path = "/",
domain = NULL,
httpOnly = NULL,
expiry = NULL,
secure = FALSE
)
Set a cookie on the domain. The inputs are required apart from
those with default values.
buttondown(buttonId = 0)
Click and hold the given mouse button (at the coordinates set by
the last moveto command). Note that the next mouse-related command
that should follow is buttondown . Any other mouse command (such
as click or another call to buttondown) will yield undefined
behaviour. buttonId - any one of 'LEFT'/0 'MIDDLE'/1 'RIGHT'/2.
Defaults to 'LEFT'
buttonup(buttonId = 0)
Releases the mouse button previously held (where the mouse is
currently at). Must be called once for every buttondown command
issued. See the note in click and buttondown about implications of
out-of-order commands. buttonId - any one of 'LEFT'/0 'MIDDLE'/1
'RIGHT'/2. Defaults to 'LEFT'
click(buttonId = 0)
Click any mouse button (at the coordinates set by the last
mouseMoveToLocation() command). buttonId - any one of 'LEFT'/0
'MIDDLE'/1 'RIGHT'/2. Defaults to 'LEFT'
close()
Close the current session.
closeServer()
Closes the server in practice terminating the process. This is
useful for linux systems. On windows the java binary operates as a
separate shell which the user can terminate.
closeWindow()
Close the current window.
deleteAllCookies()
Delete all cookies visible to the current page.
deleteCookieNamed(name)
Delete the cookie with the given name. This command will be a
no-op if there is no such cookie visible to the current page.
dismissAlert()
Dismisses the currently displayed alert dialog. For confirm() and
prompt() dialogs, this is equivalent to clicking the 'Cancel'
button. For alert() dialogs, this is equivalent to clicking the
'OK' button.
doubleclick(buttonId = 0)
Double-Click any mouse button (at the coordinates set by the last
mouseMoveToLocation() command). buttonId - any one of 'LEFT'/0
'MIDDLE'/1 'RIGHT'/2. Defaults to 'LEFT'
executeAsyncScript(script, args = list())
Inject a snippet of JavaScript into the page for execution in the
context of the currently selected frame. The executed script is
assumed to be asynchronous and must signal that is done by
invoking the provided callback, which is always provided as the
final argument to the function. The value to this callback will be
returned to the client. Asynchronous script commands may not span
page loads. If an unload event is fired while waiting for a script
result, an error should be returned to the client.
executeScript(script, args = list(""))
Inject a snippet of JavaScript into the page for execution in the
context of the currently selected frame. The executed script is
assumed to be synchronous and the result of evaluating the script
is returned to the client. The script argument defines the script
to execute in the form of a function body. The value returned by
that function will be returned to the client. The function will be
invoked with the provided args array and the values may be
accessed via the arguments object in the order specified.
Arguments may be any JSON-primitive, array, or JSON object. JSON
objects that define a WebElement reference will be converted to
the corresponding DOM element. Likewise, any WebElements in the
script result will be returned to the client as WebElement JSON
objects.
findElement(
using = c("xpath", "css selector", "id", "name", "tag name", "class name", "link text",
"partial link text"),
value
)
Search for an element on the page, starting from the document
root. The located element will be returned as an object of
webElement class.The inputs are:
using
:
Locator scheme to use to search the
element, available schemes: Defaults to 'xpath'. Partial
string matching is accepted.
- "class name" :
Returns an element whose class name
contains the search value; compound class names are not
permitted.
"css selector" :
Returns an element matching a CSS
selector.
"id" :
Returns an element whose ID attribute
matches the search value.
"name" :
Returns an element whose NAME attribute
matches the search value.
"link text" :
Returns an anchor element whose
visible text matches the search value.
"partial link text" :
Returns an anchor element
whose visible text partially matches the search value.
"tag name" :
Returns an element whose tag name
matches the search value.
"xpath" :
Returns an element matching an XPath
expression.
value
:
The search target. See examples.
findElements(
using = c("xpath", "css selector", "id", "name", "tag name", "class name", "link text",
"partial link text"),
value
)
Search for multiple elements on the page, starting from the
document root. The located elements will be returned as an list of
objects of class WebElement. The inputs are:
using
:
Locator scheme to use to search the
element, available schemes: "class name", "css selector",
"id", "name", "link text", "partial link text",
"tag name", "xpath" . Defaults to 'xpath'. Partial string
matching is accepted. See the findElement method for details
value
:
The search target. See examples.
getActiveElement()
Get the element on the page that currently has focus. The located
element will be returned as a WebElement id.
getAlertText()
Gets the text of the currently displayed JavaScript alert(),
confirm() or prompt() dialog.
getAllCookies()
Retrieve all cookies visible to the current page. Each cookie
will be returned as a list with the following name and value types:
name
:
character
value
:
character
path
:
character
domain
:
character
secure
:
logical
getCurrentUrl()
Retrieve the url of the current page.
getCurrentWindowHandle()
Retrieve the current window handle.
getLogTypes()
Get available log types. Common log types include 'client' = Logs
from the client, 'driver' = Logs from the webdriver, 'browser' =
Logs from the browser, 'server' = Logs from the server. Other log
types, for instance, for performance logging may also be
available. phantomjs for example returns a har log type which is a
single-entry log, with the HAR (HTTP Archive) of the current
webpage, since the first load (it's cleared at every unload event)
getPageSource(...)
Get the current page source.
getSessions()
Returns a list of the currently active sessions. Each session
will be returned as a list containing amongst other items:
id
:
The session ID
capabilities
:
An object describing session's
capabilities
getStatus()
Query the server's current status. All server implementations
should return two basic objects describing the server's current
platform and when the server was built.
getTitle(url)
Get the current page title.
getWindowHandles()
Retrieve the list of window handles used in the session.
getWindowPosition(windowId = "current")
Retrieve the window position. `windowid` is optional (default is
'current' window). Can pass an appropriate `handle`
getWindowSize(windowId = "current")
Retrieve the window size. `windowid` is optional (default is
'current' window). Can pass an appropriate `handle`
goBack()
Equivalent to hitting the back button on the browser.
goForward()
Equivalent to hitting the forward button on the browser.
log(type)
Get the log for a given log type. Log buffer is reset after each
request.
type
:
The log type. Typically 'client', 'driver',
'browser', 'server'
maxWindowSize(winHand = "current")
Set the size of the browser window to maximum. The windows handle
is optional. If not specified the current window in focus is used.
mouseMoveToLocation(x = NA_integer_, y = NA_integer_, webElement = NULL)
Move the mouse by an offset of the specified element. If no
element is specified, the move is relative to the current mouse
cursor. If an element is provided but no offset, the mouse will be
moved to the center of the element. If the element is not visible,
it will be scrolled into view.
navigate(url)
Navigate to a given url.
open(silent = FALSE)
Send a request to the remote server to instantiate the browser.
phantomExecute(script, args = list())
This API allows you to send a string of JavaScript via 'script',
written for PhantomJS, and be interpreted within the context of a
WebDriver Page. In other words, for the given script then this
variable is initialized to be the current Page. See
https://github.com/ariya/phantomjs/wiki/API-Reference-WebPage
and the example in this help file. NOTE: Calling the PhantomJS API
currently only works when PhantomJS is driven directly via
phantom
quit()
Delete the session & close open browsers.
refresh()
Reload the current page.
screenshot(display = FALSE, useViewer = TRUE, file = NULL)
Take a screenshot of the current page. The screenshot is returned
as a base64 encoded PNG. If display is TRUE the screenshot is
displayed locally. If useViewer is TRUE and RStudio is in use the
screenshot is displayed in the RStudio viewer panel. If file is
not NULL and display = FALSE the screenshot is written to the file
denoted by file.
sendKeysToActiveElement(sendKeys)
Send a sequence of key strokes to the active element. This
command is similar to the send keys command in every aspect except
the implicit termination: The modifiers are not released at the
end of the call. Rather, the state of the modifier keys is kept
between calls, so mouse interactions can be performed while
modifier keys are depressed. The key strokes are sent as a list.
Plain text is enter as an unnamed element of the list. Keyboard
entries are defined in `selKeys` and should be listed with name
`key`. See the examples.
sendKeysToAlert(sendKeys)
Sends keystrokes to a JavaScript prompt() or alert() dialog.
The key strokes are sent as a list. Plain text is enter as an
unnamed element of the list. Keyboard entries are defined in
`selKeys` and should be listed with name `key`. See the examples.
setAsyncScriptTimeout(milliseconds = 10000)
Set the amount of time, in milliseconds, that asynchronous
scripts executed by execute_async_script() are permitted to run
before they are aborted and a |Timeout| error is returned to the
client.
setImplicitWaitTimeout(milliseconds = 10000)
Set the amount of time the driver should wait when searching for
elements. When searching for a single element, the driver will poll
the page until an element is found or the timeout expires,
whichever occurs first. When searching for multiple elements, the
driver should poll the page until at least one element is found or
the timeout expires, at which point it will return an empty list.
If this method is never called, the driver will default to an
implicit wait of 0ms.
setTimeout(type = "page load", milliseconds = 10000)
Configure the amount of time that a particular type of operation
can execute for before they are aborted and a |Timeout| error is
returned to the client.
type
:
The type of operation to set the timeout
for. Valid values are: "script" for script timeouts,
"implicit" for modifying the implicit wait timeout and
"page load" for setting a page load timeout. Defaults to
"page load"
milliseconds
:
The amount of time, in
milliseconds, that time-limited commands are permitted to run.
Defaults to 10000 milliseconds.
setWindowPosition(x, y, winHand = "current")
Set the position (on screen) where you want your browser to be
displayed. The windows handle is optional. If not specified the
current window in focus is used.
setWindowSize(width, height, winHand = "current")
Set the size of the browser window. The windows handle is
optional. If not specified the current window in focus is used.
switchToFrame(Id)
Change focus to another frame on the page. Id can be
string|number|null|WebElement Object. If the Id is null, the
server should switch to the page's default content.
switchToWindow(windowId)
Change focus to another window. The window to change focus to may
be specified by its server assigned window handle, or by the value
of its name attribute.