Title: | R Client Implementing the W3C WebDriver Specification |
---|---|
Description: | The W3C WebDriver specification defines a way for out-of-process programs to remotely instruct the behaviour of web browsers. It is detailed at <https://w3c.github.io/webdriver/webdriver-spec.html>. This package provides an R client implementing the W3C specification. |
Authors: | John Harrison [aut, cre] |
Maintainer: | John Harrison <[email protected]> |
License: | GPL-3 |
Version: | 0.3.9 |
Built: | 2024-11-03 03:55:47 UTC |
Source: | https://github.com/johndharrison/seleniumpipes |
acceptAlert
accept a JavaScript alert
acceptAlert(remDr, ...)
acceptAlert(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other userPrompts functions: dismissAlert
,
getAlertText
, sendAlertText
## Not run: remDr <- remoteDr() remDr %>% go("https://www.google.com/ncr") %>% getTitle() sScript <- "setTimeout(function(){alert('HELLO')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% dismissAlert() sScript <- "setTimeout(function(){confirm('Press a button')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% acceptAlert() sScript <- "setTimeout(function(){confirm('Press a button')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% getAlertText() remDr %>% dismissAlert() sScript <- "setTimeout(function(){prompt('Please enter your name', '')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% getAlertText() remDr %>% sendAlertText("Buck Rogers?") remDr %>% deleteSession() ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("https://www.google.com/ncr") %>% getTitle() sScript <- "setTimeout(function(){alert('HELLO')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% dismissAlert() sScript <- "setTimeout(function(){confirm('Press a button')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% acceptAlert() sScript <- "setTimeout(function(){confirm('Press a button')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% getAlertText() remDr %>% dismissAlert() sScript <- "setTimeout(function(){prompt('Please enter your name', '')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% getAlertText() remDr %>% sendAlertText("Buck Rogers?") remDr %>% deleteSession() ## End(Not run)
acceptAlertOld
accept a JavaScript alert This uses the old
JSONwireprotocol endpoints.
acceptAlertOld(remDr, ...)
acceptAlertOld(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other oldMethods functions: dismissAlertOld
,
executeAsyncScriptOld
,
executeScriptOld
,
getAlertTextOld
,
getWindowHandleOld
,
getWindowHandlesOld
,
getWindowPositionOld
,
getWindowSizeOld
,
maximizeWindowOld
,
sendAlertTextOld
,
setWindowPositionOld
,
setWindowSizeOld
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
addCookie
Add a specific cookie.
addCookie(remDr, name, value, path = NULL, domain = NULL, secure = FALSE, httpOnly = NULL, expiry = NULL, ...)
addCookie(remDr, name, value, path = NULL, domain = NULL, secure = FALSE, httpOnly = NULL, expiry = NULL, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
name |
character: The name of the cookie; may not be null or an empty string |
value |
character: The cookie value; may not be null. |
path |
character: The path the cookie is visible to. If left blank or set to null, will be set to "/". |
domain |
character: The domain the cookie is visible to. It should be null or the same as the domain of the current URL. |
secure |
logical: Whether this cookie requires a secure connection(https?). It should be null or equal to the security of the current URL. |
httpOnly |
logical: Whether the cookie is an httpOnly cookie. |
expiry |
The cookie's expiration date; may be null. |
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other cookies functions: deleteAllCookies
,
deleteCookie
, getAllCookies
,
getNamedCookie
## Not run: # assume a server is running at default location remDr <- remoteDr() remDr %>% go("https://www.google.com/ncr") %>% getTitle() # get the cookies remDr %>% getCookie() # get a named cookie remDr %>% getCookie("NID") # add our own cookie remDr %>% addCookie(name = "myCookie", value = "12") # check its value remDr %>% getCookie("myCookie") # delete our cookie remDr %>% deleteCookie("myCookie") # check its deleted remDr %>% getCookie("myCookie") # delete all cookies remDr %>% getCookie() remDr %>% deleteAllCookies() %>% getCookie() remDr %>% deleteSession() ## End(Not run)
## Not run: # assume a server is running at default location remDr <- remoteDr() remDr %>% go("https://www.google.com/ncr") %>% getTitle() # get the cookies remDr %>% getCookie() # get a named cookie remDr %>% getCookie("NID") # add our own cookie remDr %>% addCookie(name = "myCookie", value = "12") # check its value remDr %>% getCookie("myCookie") # delete our cookie remDr %>% deleteCookie("myCookie") # check its deleted remDr %>% getCookie("myCookie") # delete all cookies remDr %>% getCookie() remDr %>% deleteAllCookies() %>% getCookie() remDr %>% deleteSession() ## End(Not run)
back
Navigate backwards in the browser history, if possible.
back(remDr, ...)
back(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other navigation functions: forward
,
getCurrentUrl
, getTitle
,
go
, refresh
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # get the title remDr %>% getTitle # get the current page url remDr %>% getCurrentUrl # navigate remDr %>% go("http://www.bbc.co.uk") # go back remDr %>% (seleniumPipes::back) # go forward remDr %>% forward # refresh page remDr %>% refresh # close browser remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # get the title remDr %>% getTitle # get the current page url remDr %>% getCurrentUrl # navigate remDr %>% go("http://www.bbc.co.uk") # go back remDr %>% (seleniumPipes::back) # go forward remDr %>% forward # refresh page remDr %>% refresh # close browser remDr %>% deleteSession ## End(Not run)
checkResponse
checks the response from a remote web driver and
checks against known errors. uses statusCodes in sysdata.rda see
seleniumPipes:::statusCodes
checkResponse(response)
checkResponse(response)
response |
The value returned by a http method from httr see
|
Stops with appropriate error if any found. On error
errorResponse
and errorContent
may
provide additional detail.
## Not run: # internal method ## End(Not run)
## Not run: # internal method ## End(Not run)
closeWindow
Close the current window.
closeWindow(remDr, ...)
closeWindow(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other commandContexts functions: fullscreenWindow
,
getWindowHandles
,
getWindowHandle
,
getWindowPosition
,
getWindowSize
,
maximizeWindow
,
setWindowPosition
,
setWindowSize
, switchToFrame
,
switchToParentFrame
,
switchToWindow
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
deleteAllCookies
Delete all the cookies that are currently
visible.
deleteAllCookies(remDr, ...)
deleteAllCookies(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other cookies functions: addCookie
,
deleteCookie
, getAllCookies
,
getNamedCookie
## Not run: # assume a server is running at default location remDr <- remoteDr() remDr %>% go("https://www.google.com/ncr") %>% getTitle() # get the cookies remDr %>% getCookie() # get a named cookie remDr %>% getCookie("NID") # add our own cookie remDr %>% addCookie(name = "myCookie", value = "12") # check its value remDr %>% getCookie("myCookie") # delete our cookie remDr %>% deleteCookie("myCookie") # check its deleted remDr %>% getCookie("myCookie") # delete all cookies remDr %>% getCookie() remDr %>% deleteAllCookies() %>% getCookie() remDr %>% deleteSession() ## End(Not run)
## Not run: # assume a server is running at default location remDr <- remoteDr() remDr %>% go("https://www.google.com/ncr") %>% getTitle() # get the cookies remDr %>% getCookie() # get a named cookie remDr %>% getCookie("NID") # add our own cookie remDr %>% addCookie(name = "myCookie", value = "12") # check its value remDr %>% getCookie("myCookie") # delete our cookie remDr %>% deleteCookie("myCookie") # check its deleted remDr %>% getCookie("myCookie") # delete all cookies remDr %>% getCookie() remDr %>% deleteAllCookies() %>% getCookie() remDr %>% deleteSession() ## End(Not run)
deleteCookie
Delete the cookie with the give name.
deleteCookie(remDr, name = NULL, ...)
deleteCookie(remDr, name = NULL, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
name |
character: The name of the cookie; may not be null or an empty string |
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other cookies functions: addCookie
,
deleteAllCookies
,
getAllCookies
, getNamedCookie
## Not run: # assume a server is running at default location remDr <- remoteDr() remDr %>% go("https://www.google.com/ncr") %>% getTitle() # get the cookies remDr %>% getCookie() # get a named cookie remDr %>% getCookie("NID") # add our own cookie remDr %>% addCookie(name = "myCookie", value = "12") # check its value remDr %>% getCookie("myCookie") # delete our cookie remDr %>% deleteCookie("myCookie") # check its deleted remDr %>% getCookie("myCookie") # delete all cookies remDr %>% getCookie() remDr %>% deleteAllCookies() %>% getCookie() remDr %>% deleteSession() ## End(Not run)
## Not run: # assume a server is running at default location remDr <- remoteDr() remDr %>% go("https://www.google.com/ncr") %>% getTitle() # get the cookies remDr %>% getCookie() # get a named cookie remDr %>% getCookie("NID") # add our own cookie remDr %>% addCookie(name = "myCookie", value = "12") # check its value remDr %>% getCookie("myCookie") # delete our cookie remDr %>% deleteCookie("myCookie") # check its deleted remDr %>% getCookie("myCookie") # delete all cookies remDr %>% getCookie() remDr %>% deleteAllCookies() %>% getCookie() remDr %>% deleteSession() ## End(Not run)
deleteSession
Delete the session.
deleteSession(remDr, ...)
deleteSession(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
Returns an object of class "rDriver". The sessionId associated with this driver has been removed however and the associated browser should be closed by the server.
Other sessions functions: getTimeouts
,
newSession
, setTimeouts
,
status
## Not run: # start a driver without opening a browser remDr <- remoteDr(newSession = FALSE) # open a broswer remDr %>% newSession # set timeout on waiting for elements remDr %>% setTimeout(type = "implicit", 5000) # close Session remDr %>% deleteSession ## End(Not run)
## Not run: # start a driver without opening a browser remDr <- remoteDr(newSession = FALSE) # open a broswer remDr %>% newSession # set timeout on waiting for elements remDr %>% setTimeout(type = "implicit", 5000) # close Session remDr %>% deleteSession ## End(Not run)
dismissAlert
dismiss a JavaScript alert
dismissAlert(remDr, ...)
dismissAlert(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other userPrompts functions: acceptAlert
,
getAlertText
, sendAlertText
## Not run: remDr <- remoteDr() remDr %>% go("https://www.google.com/ncr") %>% getTitle() sScript <- "setTimeout(function(){alert('HELLO')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% dismissAlert() sScript <- "setTimeout(function(){confirm('Press a button')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% acceptAlert() sScript <- "setTimeout(function(){confirm('Press a button')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% getAlertText() remDr %>% dismissAlert() sScript <- "setTimeout(function(){prompt('Please enter your name', '')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% getAlertText() remDr %>% sendAlertText("Buck Rogers?") remDr %>% deleteSession() ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("https://www.google.com/ncr") %>% getTitle() sScript <- "setTimeout(function(){alert('HELLO')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% dismissAlert() sScript <- "setTimeout(function(){confirm('Press a button')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% acceptAlert() sScript <- "setTimeout(function(){confirm('Press a button')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% getAlertText() remDr %>% dismissAlert() sScript <- "setTimeout(function(){prompt('Please enter your name', '')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% getAlertText() remDr %>% sendAlertText("Buck Rogers?") remDr %>% deleteSession() ## End(Not run)
dismissAlertOld
dismiss a JavaScript alert. This uses the old
JSONwireprotocol endpoints.
dismissAlertOld(remDr, ...)
dismissAlertOld(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other oldMethods functions: acceptAlertOld
,
executeAsyncScriptOld
,
executeScriptOld
,
getAlertTextOld
,
getWindowHandleOld
,
getWindowHandlesOld
,
getWindowPositionOld
,
getWindowSizeOld
,
maximizeWindowOld
,
sendAlertTextOld
,
setWindowPositionOld
,
setWindowSizeOld
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
elementClear
Clear a TEXTAREA or text INPUT element's value.
elementClear(webElem, ...)
elementClear(webElem, ...)
webElem |
An object of class "wElement". A web Element object see
|
... |
Additonal function arguments - Currently passes the
|
invisible(webElem): An object of class "wElement" is invisibly
returned. A webElement object see wbElement
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other elementInteraction functions: elementClick
,
elementSendKeys
## Not run: # start a brower remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") queryBox <- remDr %>% findElement("name", "q") # send text to the query box queryBox %>% elementSendKeys("Some ", "text") # clear the query box queryBox %>% elementClear # get the search button searchBtn <- remDr %>% findElement("name", "btnG") # send text to query box queryBox %>% elementSendKeys("R project") # click the search button searchBtn %>% elementClick # close browser remDr %>% deleteSession ## End(Not run)
## Not run: # start a brower remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") queryBox <- remDr %>% findElement("name", "q") # send text to the query box queryBox %>% elementSendKeys("Some ", "text") # clear the query box queryBox %>% elementClear # get the search button searchBtn <- remDr %>% findElement("name", "btnG") # send text to query box queryBox %>% elementSendKeys("R project") # click the search button searchBtn %>% elementClick # close browser remDr %>% deleteSession ## End(Not run)
elementClick
The elementClick function scrolls into view the
element and clicks the in-view centre point. If the element is not
pointer-interactable, an element not interactable error is returned.
elementClick(webElem, ...)
elementClick(webElem, ...)
webElem |
An object of class "wElement". A web Element object see
|
... |
Additonal function arguments - Currently passes the
|
invisible(webElem): An object of class "wElement" is invisibly
returned. A webElement object see wbElement
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other elementInteraction functions: elementClear
,
elementSendKeys
## Not run: # start a brower remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") queryBox <- remDr %>% findElement("name", "q") # send text to the query box queryBox %>% elementSendKeys("Some ", "text") # clear the query box queryBox %>% elementClear # get the search button searchBtn <- remDr %>% findElement("name", "btnG") # send text to query box queryBox %>% elementSendKeys("R project") # click the search button searchBtn %>% elementClick # close browser remDr %>% deleteSession ## End(Not run)
## Not run: # start a brower remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") queryBox <- remDr %>% findElement("name", "q") # send text to the query box queryBox %>% elementSendKeys("Some ", "text") # clear the query box queryBox %>% elementClear # get the search button searchBtn <- remDr %>% findElement("name", "btnG") # send text to query box queryBox %>% elementSendKeys("R project") # click the search button searchBtn %>% elementClick # close browser remDr %>% deleteSession ## End(Not run)
elementSendKeys
The elementSendKeys function scrolls into view
the form control element and then sends the provided keys to the
element. In case the element is not keyboard interactable, an
element not interactable error is returned.
elementSendKeys(webElem, ...)
elementSendKeys(webElem, ...)
webElem |
An object of class "wElement". A web Element object see
|
... |
keys to send the element. |
invisible(webElem): An object of class "wElement" is invisibly
returned. A webElement object see wbElement
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other elementInteraction functions: elementClear
,
elementClick
## Not run: # start a brower remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") queryBox <- remDr %>% findElement("name", "q") # send text to the query box queryBox %>% elementSendKeys("Some ", "text") # clear the query box queryBox %>% elementClear # get the search button searchBtn <- remDr %>% findElement("name", "btnG") # send text to query box queryBox %>% elementSendKeys("R project") # click the search button searchBtn %>% elementClick # close browser remDr %>% deleteSession ## End(Not run)
## Not run: # start a brower remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") queryBox <- remDr %>% findElement("name", "q") # send text to the query box queryBox %>% elementSendKeys("Some ", "text") # clear the query box queryBox %>% elementClear # get the search button searchBtn <- remDr %>% findElement("name", "btnG") # send text to query box queryBox %>% elementSendKeys("R project") # click the search button searchBtn %>% elementClick # close browser remDr %>% deleteSession ## End(Not run)
errorContent
returns the content from the remote webdriver on an
error.
errorContent()
errorContent()
returns content see content
## Not run: remDr <- remoteDr() remDr %>% findElement("name", "sdofnsdofk") errorContent() ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% findElement("name", "sdofnsdofk") errorContent() ## End(Not run)
errorResponse
returns the response from the remote webdriver on
an error.
errorResponse()
errorResponse()
returns response see VERB
. Headers, request etc.
can be examined from this object.
## Not run: remDr <- remoteDr() remDr %>% findElement("name", "sdofnsdofk") errorResponse() ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% findElement("name", "sdofnsdofk") errorResponse() ## End(Not run)
executeAsyncScript
Inject a snippet of JavaScript into the page
for asynchronous execution in the context of the currently selected
frame.
executeAsyncScript(remDr, script, args = list(), replace = TRUE, ...)
executeAsyncScript(remDr, script, args = list(), replace = TRUE, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
script |
character: The script to inject. |
args |
The arguments of the script as a list. |
replace |
logical: If TRUE any elements identify as web Elements are converted to such. |
... |
Additonal function arguments - Currently passes the
|
The driver will pass a callback as the last argument to the snippet, and block until the callback is invoked.
If replace is TRUE parses the response from the server for web Elements and converts as such. Otherwise the content returned is assummed to be a simple list.
Other documentHandling functions: executeScript
,
getPageSource
## Not run: remDr <- remoteDr() # Get the page source remDr %>% go("https://www.google.com/ncr") %>% getPageSource remDr %>% getTitle() webElem <- remDr %>% findElement("css", "img#hplogo") # check if the logo is hidden remDr %>% executeScript("return document.getElementById('hplogo').hidden;", args = list()) # [1] FALSE # hide the logo remDr %>% executeScript("document.getElementById('hplogo').hidden = true;", args = list()) # Make the logo visible this time passing a web Element as an argument remDr %>% executeScript(script = "return arguments[0].hidden = false;", args = list(webElem)) # Pass arguments remDr %>% executeScript(script = "return argument[1] + argument[2];" , args = list(1, 2)) # Return a web Element remDr %>% executeScript( script = "return document.getElementById('hplogo');", args = list()) # ElementId: 0 # Remote Driver: # Remote Ip Address: http://localhost:4444/wd/hub # Remote sessionId: 9a83672a-d72b-4873-aa7d-96f7f1f80fa0 # Return a web Element in a more complex object script <- "var test ={num:1, str:'a', el:document.getElementById('hplogo')}; return test;" remDr %>% executeScript(script = script , args = list()) # $str # [1] "a" # # $num # [1] 1 # # $el # ElementId: 0 # Remote Driver: # Remote Ip Address: http://localhost:4444/wd/hub # Remote sessionId: 9a83672a-d72b-4873-aa7d-96f7f1f80fa0 # Run with replace = FALSE remDr %>% executeScript(script = script , args = list(), replace = FALSE) # $str # [1] "a" # # $num # [1] 1 # # $el # $el$ELEMENT # [1] "0" remDr %>% setTimeout("script") asScript <- "cb = arguments[0];setTimeout(function(){cb('DONE');},5000); " system.time(test1 <- remDr %>% executeAsyncScript(asScript, args = list())) sScript <- "setTimeout(function(){},5000); return 'DONE';" system.time(test2 <- remDr %>% executeScript(sScript, args = list())) remDr %>% deleteSession() ## End(Not run)
## Not run: remDr <- remoteDr() # Get the page source remDr %>% go("https://www.google.com/ncr") %>% getPageSource remDr %>% getTitle() webElem <- remDr %>% findElement("css", "img#hplogo") # check if the logo is hidden remDr %>% executeScript("return document.getElementById('hplogo').hidden;", args = list()) # [1] FALSE # hide the logo remDr %>% executeScript("document.getElementById('hplogo').hidden = true;", args = list()) # Make the logo visible this time passing a web Element as an argument remDr %>% executeScript(script = "return arguments[0].hidden = false;", args = list(webElem)) # Pass arguments remDr %>% executeScript(script = "return argument[1] + argument[2];" , args = list(1, 2)) # Return a web Element remDr %>% executeScript( script = "return document.getElementById('hplogo');", args = list()) # ElementId: 0 # Remote Driver: # Remote Ip Address: http://localhost:4444/wd/hub # Remote sessionId: 9a83672a-d72b-4873-aa7d-96f7f1f80fa0 # Return a web Element in a more complex object script <- "var test ={num:1, str:'a', el:document.getElementById('hplogo')}; return test;" remDr %>% executeScript(script = script , args = list()) # $str # [1] "a" # # $num # [1] 1 # # $el # ElementId: 0 # Remote Driver: # Remote Ip Address: http://localhost:4444/wd/hub # Remote sessionId: 9a83672a-d72b-4873-aa7d-96f7f1f80fa0 # Run with replace = FALSE remDr %>% executeScript(script = script , args = list(), replace = FALSE) # $str # [1] "a" # # $num # [1] 1 # # $el # $el$ELEMENT # [1] "0" remDr %>% setTimeout("script") asScript <- "cb = arguments[0];setTimeout(function(){cb('DONE');},5000); " system.time(test1 <- remDr %>% executeAsyncScript(asScript, args = list())) sScript <- "setTimeout(function(){},5000); return 'DONE';" system.time(test2 <- remDr %>% executeScript(sScript, args = list())) remDr %>% deleteSession() ## End(Not run)
executeAsyncScriptOld
This function uses the old JSONwireprotocol
end points. Inject a snippet of JavaScript into the page for
asynchronous execution in the context of the currently selected
frame.
executeAsyncScriptOld(remDr, script, args = list(), replace = TRUE, ...)
executeAsyncScriptOld(remDr, script, args = list(), replace = TRUE, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
script |
character: The script to inject. |
args |
The arguments of the script as a list. |
replace |
logical: If TRUE any elements identify as web Elements are converted to such. |
... |
Additonal function arguments - Currently passes the
|
The driver will pass a callback as the last argument to the snippet, and block until the callback is invoked.
If replace is TRUE parses the response from the server for web Elements and converts as such. Otherwise the content returned is assummed to be a simple list.
Other oldMethods functions: acceptAlertOld
,
dismissAlertOld
,
executeScriptOld
,
getAlertTextOld
,
getWindowHandleOld
,
getWindowHandlesOld
,
getWindowPositionOld
,
getWindowSizeOld
,
maximizeWindowOld
,
sendAlertTextOld
,
setWindowPositionOld
,
setWindowSizeOld
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
executeScript
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 will be returned.
executeScript(remDr, script, args = list(), replace = TRUE, ...)
executeScript(remDr, script, args = list(), replace = TRUE, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
script |
character: The script to inject. |
args |
The arguments of the script as a list. |
replace |
logical: If TRUE any elements identify as web Elements are converted to such. |
... |
Additonal function arguments - Currently passes the
|
If replace is TRUE parses the response from the server for web Elements and converts as such. Otherwise the content returned is assummed to be a simple list.
Other documentHandling functions: executeAsyncScript
,
getPageSource
## Not run: remDr <- remoteDr() # Get the page source remDr %>% go("https://www.google.com/ncr") %>% getPageSource remDr %>% getTitle() webElem <- remDr %>% findElement("css", "img#hplogo") # check if the logo is hidden remDr %>% executeScript("return document.getElementById('hplogo').hidden;", args = list()) # [1] FALSE # hide the logo remDr %>% executeScript("document.getElementById('hplogo').hidden = true;", args = list()) # Make the logo visible this time passing a web Element as an argument remDr %>% executeScript(script = "return arguments[0].hidden = false;", args = list(webElem)) # Pass arguments remDr %>% executeScript(script = "return argument[1] + argument[2];" , args = list(1, 2)) # Return a web Element remDr %>% executeScript( script = "return document.getElementById('hplogo');", args = list()) # ElementId: 0 # Remote Driver: # Remote Ip Address: http://localhost:4444/wd/hub # Remote sessionId: 9a83672a-d72b-4873-aa7d-96f7f1f80fa0 # Return a web Element in a more complex object script <- "var test ={num:1, str:'a', el:document.getElementById('hplogo')}; return test;" remDr %>% executeScript(script = script , args = list()) # $str # [1] "a" # # $num # [1] 1 # # $el # ElementId: 0 # Remote Driver: # Remote Ip Address: http://localhost:4444/wd/hub # Remote sessionId: 9a83672a-d72b-4873-aa7d-96f7f1f80fa0 # Run with replace = FALSE remDr %>% executeScript(script = script , args = list(), replace = FALSE) # $str # [1] "a" # # $num # [1] 1 # # $el # $el$ELEMENT # [1] "0" remDr %>% setTimeout("script") asScript <- "cb = arguments[0];setTimeout(function(){cb('DONE');},5000); " system.time(test1 <- remDr %>% executeAsyncScript(asScript, args = list())) sScript <- "setTimeout(function(){},5000); return 'DONE';" system.time(test2 <- remDr %>% executeScript(sScript, args = list())) remDr %>% deleteSession() ## End(Not run)
## Not run: remDr <- remoteDr() # Get the page source remDr %>% go("https://www.google.com/ncr") %>% getPageSource remDr %>% getTitle() webElem <- remDr %>% findElement("css", "img#hplogo") # check if the logo is hidden remDr %>% executeScript("return document.getElementById('hplogo').hidden;", args = list()) # [1] FALSE # hide the logo remDr %>% executeScript("document.getElementById('hplogo').hidden = true;", args = list()) # Make the logo visible this time passing a web Element as an argument remDr %>% executeScript(script = "return arguments[0].hidden = false;", args = list(webElem)) # Pass arguments remDr %>% executeScript(script = "return argument[1] + argument[2];" , args = list(1, 2)) # Return a web Element remDr %>% executeScript( script = "return document.getElementById('hplogo');", args = list()) # ElementId: 0 # Remote Driver: # Remote Ip Address: http://localhost:4444/wd/hub # Remote sessionId: 9a83672a-d72b-4873-aa7d-96f7f1f80fa0 # Return a web Element in a more complex object script <- "var test ={num:1, str:'a', el:document.getElementById('hplogo')}; return test;" remDr %>% executeScript(script = script , args = list()) # $str # [1] "a" # # $num # [1] 1 # # $el # ElementId: 0 # Remote Driver: # Remote Ip Address: http://localhost:4444/wd/hub # Remote sessionId: 9a83672a-d72b-4873-aa7d-96f7f1f80fa0 # Run with replace = FALSE remDr %>% executeScript(script = script , args = list(), replace = FALSE) # $str # [1] "a" # # $num # [1] 1 # # $el # $el$ELEMENT # [1] "0" remDr %>% setTimeout("script") asScript <- "cb = arguments[0];setTimeout(function(){cb('DONE');},5000); " system.time(test1 <- remDr %>% executeAsyncScript(asScript, args = list())) sScript <- "setTimeout(function(){},5000); return 'DONE';" system.time(test2 <- remDr %>% executeScript(sScript, args = list())) remDr %>% deleteSession() ## End(Not run)
executeScriptOld
This function uses the old JSONwireprotocol end
points. 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
will be returned.
executeScriptOld(remDr, script, args = list(), replace = TRUE, ...)
executeScriptOld(remDr, script, args = list(), replace = TRUE, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
script |
character: The script to inject. |
args |
The arguments of the script as a list. |
replace |
logical: If TRUE any elements identify as web Elements are converted to such. |
... |
Additonal function arguments - Currently passes the
|
If replace is TRUE parses the response from the server for web Elements and converts as such. Otherwise the content returned is assummed to be a simple list.
Other oldMethods functions: acceptAlertOld
,
dismissAlertOld
,
executeAsyncScriptOld
,
getAlertTextOld
,
getWindowHandleOld
,
getWindowHandlesOld
,
getWindowPositionOld
,
getWindowSizeOld
,
maximizeWindowOld
,
sendAlertTextOld
,
setWindowPositionOld
,
setWindowSizeOld
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
findElement
Search for an element on the page, starting from the
document root. The located element will be returned as an object of
"wElement" class
findElement(remDr, using = c("xpath", "css selector", "id", "name", "tag name", "class name", "link text", "partial link text"), value, ...)
findElement(remDr, using = c("xpath", "css selector", "id", "name", "tag name", "class name", "link text", "partial link text"), value, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
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. |
value |
The search target. See examples. |
... |
Additonal function arguments - Currently passes the
|
Details of possible locator schemes
Returns an element whose class name contains the search value; compound class names are not permitted.
Returns an element matching a CSS selector.
Returns an element whose ID attribute matches the search value.
Returns an element whose NAME attribute matches the search value.
Returns an anchor element whose visible text matches the search value.
Returns an anchor element whose visible text partially matches the search value.
Returns an element whose tag name matches the search value.
Returns an element matching an XPath expression.
invisible(wbElement(res$value, remDr)): An object of class
"wElement" is invisibly returned. A webElement object see
wbElement
. This allows for chaining from this function
to other functions that take such an object as an argument. See
examples for further details.
Other elementRetrieval functions: findElementFromElement
,
findElementsFromElement
,
findElements
,
getActiveElement
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # find the search form query box and search for "R project" webElem <- remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") # click the first link hopefully should be www.r-project.org remDr %>% findElement("css", "h3.r a") %>% elementClick # get the navigation div navElem <- remDr %>% findElement("css", "div[role='navigation']") # find all the links in this div navLinks <- navElem %>% findElementsFromElement("css", "a") # check the links nLinks <- sapply(navLinks, function(x) x %>% getElementText) # compare with all links allLinks <- remDr %>% findElements("css", "a") aLinks <- sapply(allLinks, function(x) x %>% getElementText) # show the effect of searching for elements from element aLinks %in% nLinks remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # find the search form query box and search for "R project" webElem <- remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") # click the first link hopefully should be www.r-project.org remDr %>% findElement("css", "h3.r a") %>% elementClick # get the navigation div navElem <- remDr %>% findElement("css", "div[role='navigation']") # find all the links in this div navLinks <- navElem %>% findElementsFromElement("css", "a") # check the links nLinks <- sapply(navLinks, function(x) x %>% getElementText) # compare with all links allLinks <- remDr %>% findElements("css", "a") aLinks <- sapply(allLinks, function(x) x %>% getElementText) # show the effect of searching for elements from element aLinks %in% nLinks remDr %>% deleteSession ## End(Not run)
findElementFromElement
Search for an element on the page,
starting from the node defined by the parent webElement. The located
element will be returned as an object of wElement class.
findElementFromElement(webElem, using = c("xpath", "css selector", "id", "name", "tag name", "class name", "link text", "partial link text"), value, ...)
findElementFromElement(webElem, using = c("xpath", "css selector", "id", "name", "tag name", "class name", "link text", "partial link text"), value, ...)
webElem |
An object of class "wElement". A web Element object see
|
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. |
value |
The search target. See examples. |
... |
Additonal function arguments - Currently passes the
|
Details of possible locator schemes
Returns an element whose class name contains the search value; compound class names are not permitted.
Returns an element matching a CSS selector.
Returns an element whose ID attribute matches the search value.
Returns an element whose NAME attribute matches the search value.
Returns an anchor element whose visible text matches the search value.
Returns an anchor element whose visible text partially matches the search value.
Returns an element whose tag name matches the search value.
Returns an element matching an XPath expression.
invisible(wbElement(res$value, webElem$remDr)): An object of
class "wElement" is invisibly returned. A webElement object see
wbElement
. This allows for chaining from this function
to other functions that take such an object as an argument. See
examples for further details.
Other elementRetrieval functions: findElementsFromElement
,
findElements
, findElement
,
getActiveElement
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # find the search form query box and search for "R project" webElem <- remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") # click the first link hopefully should be www.r-project.org remDr %>% findElement("css", "h3.r a") %>% elementClick # get the navigation div navElem <- remDr %>% findElement("css", "div[role='navigation']") # find all the links in this div navLinks <- navElem %>% findElementsFromElement("css", "a") # check the links nLinks <- sapply(navLinks, function(x) x %>% getElementText) # compare with all links allLinks <- remDr %>% findElements("css", "a") aLinks <- sapply(allLinks, function(x) x %>% getElementText) # show the effect of searching for elements from element aLinks %in% nLinks remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # find the search form query box and search for "R project" webElem <- remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") # click the first link hopefully should be www.r-project.org remDr %>% findElement("css", "h3.r a") %>% elementClick # get the navigation div navElem <- remDr %>% findElement("css", "div[role='navigation']") # find all the links in this div navLinks <- navElem %>% findElementsFromElement("css", "a") # check the links nLinks <- sapply(navLinks, function(x) x %>% getElementText) # compare with all links allLinks <- remDr %>% findElements("css", "a") aLinks <- sapply(allLinks, function(x) x %>% getElementText) # show the effect of searching for elements from element aLinks %in% nLinks remDr %>% deleteSession ## End(Not run)
findElements
Search for multiple elements on the page, starting
from the document root. The located elements will be returned as a
list of objects of class wElement.
findElements(remDr, using = c("xpath", "css selector", "id", "name", "tag name", "class name", "link text", "partial link text"), value, ...)
findElements(remDr, using = c("xpath", "css selector", "id", "name", "tag name", "class name", "link text", "partial link text"), value, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
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. |
value |
The search target. See examples. |
... |
Additonal function arguments - Currently passes the
|
Details of possible locator schemes
Returns an element whose class name contains the search value; compound class names are not permitted.
Returns an element matching a CSS selector.
Returns an element whose ID attribute matches the search value.
Returns an element whose NAME attribute matches the search value.
Returns an anchor element whose visible text matches the search value.
Returns an anchor element whose visible text partially matches the search value.
Returns an element whose tag name matches the search value.
Returns an element matching an XPath expression.
invisible(lapply(res$value, wbElement, remDr = remDr)): A list
of objects of class "wElement" is invisibly returned. A webElement
object see wbElement
. This allows for chaining from
this function to other functions that take such an object as an
argument. See examples for further details.
Other elementRetrieval functions: findElementFromElement
,
findElementsFromElement
,
findElement
, getActiveElement
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # find the search form query box and search for "R project" webElem <- remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") # click the first link hopefully should be www.r-project.org remDr %>% findElement("css", "h3.r a") %>% elementClick # get the navigation div navElem <- remDr %>% findElement("css", "div[role='navigation']") # find all the links in this div navLinks <- navElem %>% findElementsFromElement("css", "a") # check the links nLinks <- sapply(navLinks, function(x) x %>% getElementText) # compare with all links allLinks <- remDr %>% findElements("css", "a") aLinks <- sapply(allLinks, function(x) x %>% getElementText) # show the effect of searching for elements from element aLinks %in% nLinks remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # find the search form query box and search for "R project" webElem <- remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") # click the first link hopefully should be www.r-project.org remDr %>% findElement("css", "h3.r a") %>% elementClick # get the navigation div navElem <- remDr %>% findElement("css", "div[role='navigation']") # find all the links in this div navLinks <- navElem %>% findElementsFromElement("css", "a") # check the links nLinks <- sapply(navLinks, function(x) x %>% getElementText) # compare with all links allLinks <- remDr %>% findElements("css", "a") aLinks <- sapply(allLinks, function(x) x %>% getElementText) # show the effect of searching for elements from element aLinks %in% nLinks remDr %>% deleteSession ## End(Not run)
findElementsFromElement
Search for multiple elements on the page,
starting from the node defined by the parent webElement. The located
elements will be returned as an list of objects of class wElement.
findElementsFromElement(webElem, using = c("xpath", "css selector", "id", "name", "tag name", "class name", "link text", "partial link text"), value, ...)
findElementsFromElement(webElem, using = c("xpath", "css selector", "id", "name", "tag name", "class name", "link text", "partial link text"), value, ...)
webElem |
An object of class "wElement". A web Element object see
|
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. |
value |
The search target. See examples. |
... |
Additonal function arguments - Currently passes the
|
Details of possible locator schemes
Returns an element whose class name contains the search value; compound class names are not permitted.
Returns an element matching a CSS selector.
Returns an element whose ID attribute matches the search value.
Returns an element whose NAME attribute matches the search value.
Returns an anchor element whose visible text matches the search value.
Returns an anchor element whose visible text partially matches the search value.
Returns an element whose tag name matches the search value.
Returns an element matching an XPath expression.
invisible(lapply(res$value, wbElement, remDr = webElem$remDr)):
A list of objects of class "wElement" is invisibly returned. A
webElement object see wbElement
. This allows for
chaining from this function to other functions that take such an
object as an argument. See examples for further details.
Other elementRetrieval functions: findElementFromElement
,
findElements
, findElement
,
getActiveElement
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # find the search form query box and search for "R project" webElem <- remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") # click the first link hopefully should be www.r-project.org remDr %>% findElement("css", "h3.r a") %>% elementClick # get the navigation div navElem <- remDr %>% findElement("css", "div[role='navigation']") # find all the links in this div navLinks <- navElem %>% findElementsFromElement("css", "a") # check the links nLinks <- sapply(navLinks, function(x) x %>% getElementText) # compare with all links allLinks <- remDr %>% findElements("css", "a") aLinks <- sapply(allLinks, function(x) x %>% getElementText) # show the effect of searching for elements from element aLinks %in% nLinks remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # find the search form query box and search for "R project" webElem <- remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") # click the first link hopefully should be www.r-project.org remDr %>% findElement("css", "h3.r a") %>% elementClick # get the navigation div navElem <- remDr %>% findElement("css", "div[role='navigation']") # find all the links in this div navLinks <- navElem %>% findElementsFromElement("css", "a") # check the links nLinks <- sapply(navLinks, function(x) x %>% getElementText) # compare with all links allLinks <- remDr %>% findElements("css", "a") aLinks <- sapply(allLinks, function(x) x %>% getElementText) # show the effect of searching for elements from element aLinks %in% nLinks remDr %>% deleteSession ## End(Not run)
forward
Navigate forwards in the browser history, if possible.
forward(remDr, ...)
forward(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other navigation functions: back
,
getCurrentUrl
, getTitle
,
go
, refresh
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # get the title remDr %>% getTitle # get the current page url remDr %>% getCurrentUrl # navigate remDr %>% go("http://www.bbc.co.uk") # go back remDr %>% (seleniumPipes::back) # go forward remDr %>% forward # refresh page remDr %>% refresh # close browser remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # get the title remDr %>% getTitle # get the current page url remDr %>% getCurrentUrl # navigate remDr %>% go("http://www.bbc.co.uk") # go back remDr %>% (seleniumPipes::back) # go forward remDr %>% forward # refresh page remDr %>% refresh # close browser remDr %>% deleteSession ## End(Not run)
fullscreenWindow
The Fullscreen Window command invokes the window
manager-specific “full screen” operation, if any, on the window
containing the current top-level browsing context. This typically
increases the window to the size of the physical display and can hide
browser UI elements such as toolbars.
fullscreenWindow(remDr, ...)
fullscreenWindow(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other commandContexts functions: closeWindow
,
getWindowHandles
,
getWindowHandle
,
getWindowPosition
,
getWindowSize
,
maximizeWindow
,
setWindowPosition
,
setWindowSize
, switchToFrame
,
switchToParentFrame
,
switchToWindow
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
getActiveElement
Get the element on the page that currently has
focus. The located element will be returned as a WebcElement object.
getActiveElement(remDr, ...)
getActiveElement(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
invisible(wbElement(res$value, remDr)): An object of class
"wElement" is invisibly returned. A webElement object see
wbElement
. This allows for chaining from this function
to other functions that take such an object as an argument. See
examples for further details.
Other elementRetrieval functions: findElementFromElement
,
findElementsFromElement
,
findElements
, findElement
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # find the search form query box and search for "R project" webElem <- remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") # click the first link hopefully should be www.r-project.org remDr %>% findElement("css", "h3.r a") %>% elementClick # get the navigation div navElem <- remDr %>% findElement("css", "div[role='navigation']") # find all the links in this div navLinks <- navElem %>% findElementsFromElement("css", "a") # check the links nLinks <- sapply(navLinks, function(x) x %>% getElementText) # compare with all links allLinks <- remDr %>% findElements("css", "a") aLinks <- sapply(allLinks, function(x) x %>% getElementText) # show the effect of searching for elements from element aLinks %in% nLinks remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # find the search form query box and search for "R project" webElem <- remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") # click the first link hopefully should be www.r-project.org remDr %>% findElement("css", "h3.r a") %>% elementClick # get the navigation div navElem <- remDr %>% findElement("css", "div[role='navigation']") # find all the links in this div navLinks <- navElem %>% findElementsFromElement("css", "a") # check the links nLinks <- sapply(navLinks, function(x) x %>% getElementText) # compare with all links allLinks <- remDr %>% findElements("css", "a") aLinks <- sapply(allLinks, function(x) x %>% getElementText) # show the effect of searching for elements from element aLinks %in% nLinks remDr %>% deleteSession ## End(Not run)
getAlertText
Get the text from a JavaScript alert.
getAlertText(remDr, ...)
getAlertText(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
The text from the alert is returned.
Other userPrompts functions: acceptAlert
,
dismissAlert
, sendAlertText
## Not run: remDr <- remoteDr() remDr %>% go("https://www.google.com/ncr") %>% getTitle() sScript <- "setTimeout(function(){alert('HELLO')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% dismissAlert() sScript <- "setTimeout(function(){confirm('Press a button')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% acceptAlert() sScript <- "setTimeout(function(){confirm('Press a button')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% getAlertText() remDr %>% dismissAlert() sScript <- "setTimeout(function(){prompt('Please enter your name', '')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% getAlertText() remDr %>% sendAlertText("Buck Rogers?") remDr %>% deleteSession() ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("https://www.google.com/ncr") %>% getTitle() sScript <- "setTimeout(function(){alert('HELLO')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% dismissAlert() sScript <- "setTimeout(function(){confirm('Press a button')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% acceptAlert() sScript <- "setTimeout(function(){confirm('Press a button')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% getAlertText() remDr %>% dismissAlert() sScript <- "setTimeout(function(){prompt('Please enter your name', '')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% getAlertText() remDr %>% sendAlertText("Buck Rogers?") remDr %>% deleteSession() ## End(Not run)
getAlertTextOld
Get the text from a JavaScript alert. This uses
the old JSONwireprotocol endpoints.
getAlertTextOld(remDr, ...)
getAlertTextOld(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
The alert text is returned as a string.
Other oldMethods functions: acceptAlertOld
,
dismissAlertOld
,
executeAsyncScriptOld
,
executeScriptOld
,
getWindowHandleOld
,
getWindowHandlesOld
,
getWindowPositionOld
,
getWindowSizeOld
,
maximizeWindowOld
,
sendAlertTextOld
,
setWindowPositionOld
,
setWindowSizeOld
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
getAllCookies
Get all the cookies for the current domain.
getAllCookies(remDr, ...)
getAllCookies(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
A list of all the cookies on the current domain are returned.
These cookies have values as stipulated by the arguments given in
addCookie
.
Other cookies functions: addCookie
,
deleteAllCookies
,
deleteCookie
, getNamedCookie
## Not run: # assume a server is running at default location remDr <- remoteDr() remDr %>% go("https://www.google.com/ncr") %>% getTitle() # get the cookies remDr %>% getCookie() # get a named cookie remDr %>% getCookie("NID") # add our own cookie remDr %>% addCookie(name = "myCookie", value = "12") # check its value remDr %>% getCookie("myCookie") # delete our cookie remDr %>% deleteCookie("myCookie") # check its deleted remDr %>% getCookie("myCookie") # delete all cookies remDr %>% getCookie() remDr %>% deleteAllCookies() %>% getCookie() remDr %>% deleteSession() ## End(Not run)
## Not run: # assume a server is running at default location remDr <- remoteDr() remDr %>% go("https://www.google.com/ncr") %>% getTitle() # get the cookies remDr %>% getCookie() # get a named cookie remDr %>% getCookie("NID") # add our own cookie remDr %>% addCookie(name = "myCookie", value = "12") # check its value remDr %>% getCookie("myCookie") # delete our cookie remDr %>% deleteCookie("myCookie") # check its deleted remDr %>% getCookie("myCookie") # delete all cookies remDr %>% getCookie() remDr %>% deleteAllCookies() %>% getCookie() remDr %>% deleteSession() ## End(Not run)
getCurrentUrl
Retrieve the URL of the current page.
getCurrentUrl(remDr, ...)
getCurrentUrl(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
A character string is returned giving the current page URL.
Other navigation functions: back
,
forward
, getTitle
,
go
, refresh
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # get the title remDr %>% getTitle # get the current page url remDr %>% getCurrentUrl # navigate remDr %>% go("http://www.bbc.co.uk") # go back remDr %>% (seleniumPipes::back) # go forward remDr %>% forward # refresh page remDr %>% refresh # close browser remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # get the title remDr %>% getTitle # get the current page url remDr %>% getCurrentUrl # navigate remDr %>% go("http://www.bbc.co.uk") # go back remDr %>% (seleniumPipes::back) # go forward remDr %>% forward # refresh page remDr %>% refresh # close browser remDr %>% deleteSession ## End(Not run)
getElementAttribute
Get the value of an element's attribute.
getElementAttribute(webElem, attribute, ...)
getElementAttribute(webElem, attribute, ...)
webElem |
An object of class "wElement". A web Element object see
|
attribute |
The attribute to query as a character string. |
... |
Additonal function arguments - Currently passes the
|
The value of the attribute, or null if it is not set on the element.
Other elementState functions: getElementCssValue
,
getElementProperty
,
getElementRect
,
getElementTagName
,
getElementText
,
isElementEnabled
,
isElementSelected
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # select the search box searchElem <- remDr %>% findElement("name", "q") # get the name of our element searchElem %>% getElementAttribute("name") # get the css background-color searchElem %>% getElementCssValue("background-color") blueScript <- "arguments[0].style.backgroundColor = 'blue';" remDr %>% executeScript(blueScript, list(searchElem)) searchElem %>% getElementCssValue("background-color") # get the javascript property # searchElem %>% getElementProperty("backgroundColor") # get dimensions searchElem %>% getElementRect searchElem %>% getElementTagName # get some text and return it remDr %>% go("http://r-project.org") remDr %>% findElement("css", "h1") %>% getElementText # close browser remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # select the search box searchElem <- remDr %>% findElement("name", "q") # get the name of our element searchElem %>% getElementAttribute("name") # get the css background-color searchElem %>% getElementCssValue("background-color") blueScript <- "arguments[0].style.backgroundColor = 'blue';" remDr %>% executeScript(blueScript, list(searchElem)) searchElem %>% getElementCssValue("background-color") # get the javascript property # searchElem %>% getElementProperty("backgroundColor") # get dimensions searchElem %>% getElementRect searchElem %>% getElementTagName # get some text and return it remDr %>% go("http://r-project.org") remDr %>% findElement("css", "h1") %>% getElementText # close browser remDr %>% deleteSession ## End(Not run)
getElementCssValue
Query the value of an element's computed CSS
property. The CSS property to query should be specified using the
CSS property name, not the JavaScript property name (e.g.
background-color instead of backgroundColor).
getElementCssValue(webElem, propertyName, ...)
getElementCssValue(webElem, propertyName, ...)
webElem |
An object of class "wElement". A web Element object see
|
propertyName |
The property to query as a character string |
... |
Additonal function arguments - Currently passes the
|
The value of the specified CSS property.
Other elementState functions: getElementAttribute
,
getElementProperty
,
getElementRect
,
getElementTagName
,
getElementText
,
isElementEnabled
,
isElementSelected
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # select the search box searchElem <- remDr %>% findElement("name", "q") # get the name of our element searchElem %>% getElementAttribute("name") # get the css background-color searchElem %>% getElementCssValue("background-color") blueScript <- "arguments[0].style.backgroundColor = 'blue';" remDr %>% executeScript(blueScript, list(searchElem)) searchElem %>% getElementCssValue("background-color") # get the javascript property # searchElem %>% getElementProperty("backgroundColor") # get dimensions searchElem %>% getElementRect searchElem %>% getElementTagName # get some text and return it remDr %>% go("http://r-project.org") remDr %>% findElement("css", "h1") %>% getElementText # close browser remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # select the search box searchElem <- remDr %>% findElement("name", "q") # get the name of our element searchElem %>% getElementAttribute("name") # get the css background-color searchElem %>% getElementCssValue("background-color") blueScript <- "arguments[0].style.backgroundColor = 'blue';" remDr %>% executeScript(blueScript, list(searchElem)) searchElem %>% getElementCssValue("background-color") # get the javascript property # searchElem %>% getElementProperty("backgroundColor") # get dimensions searchElem %>% getElementRect searchElem %>% getElementTagName # get some text and return it remDr %>% go("http://r-project.org") remDr %>% findElement("css", "h1") %>% getElementText # close browser remDr %>% deleteSession ## End(Not run)
getElementProperty
Query the value of an elements property.
getElementProperty(webElem, property, ...)
getElementProperty(webElem, property, ...)
webElem |
An object of class "wElement". A web Element object see
|
property |
The property to query as a character string |
... |
Additonal function arguments - Currently passes the
|
The value of the elements specified property.
Other elementState functions: getElementAttribute
,
getElementCssValue
,
getElementRect
,
getElementTagName
,
getElementText
,
isElementEnabled
,
isElementSelected
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # select the search box searchElem <- remDr %>% findElement("name", "q") # get the name of our element searchElem %>% getElementAttribute("name") # get the css background-color searchElem %>% getElementCssValue("background-color") blueScript <- "arguments[0].style.backgroundColor = 'blue';" remDr %>% executeScript(blueScript, list(searchElem)) searchElem %>% getElementCssValue("background-color") # get the javascript property # searchElem %>% getElementProperty("backgroundColor") # get dimensions searchElem %>% getElementRect searchElem %>% getElementTagName # get some text and return it remDr %>% go("http://r-project.org") remDr %>% findElement("css", "h1") %>% getElementText # close browser remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # select the search box searchElem <- remDr %>% findElement("name", "q") # get the name of our element searchElem %>% getElementAttribute("name") # get the css background-color searchElem %>% getElementCssValue("background-color") blueScript <- "arguments[0].style.backgroundColor = 'blue';" remDr %>% executeScript(blueScript, list(searchElem)) searchElem %>% getElementCssValue("background-color") # get the javascript property # searchElem %>% getElementProperty("backgroundColor") # get dimensions searchElem %>% getElementRect searchElem %>% getElementTagName # get some text and return it remDr %>% go("http://r-project.org") remDr %>% findElement("css", "h1") %>% getElementText # close browser remDr %>% deleteSession ## End(Not run)
getElementRect
The getElementRect fuinction returns the
dimensions and coordinates of the given web element.
getElementRect(webElem, ...)
getElementRect(webElem, ...)
webElem |
An object of class "wElement". A web Element object see
|
... |
Additonal function arguments - Currently passes the
|
The returned value is a list including the following members:
X axis position of the top-left corner of the web element relative to the current browsing context’s document element in CSS reference pixels.
Y axis position of the top-left corner of the web element relative to the current browsing context’s document element in CSS reference pixels.
Height of the web element’s bounding rectangle in CSS reference pixels.
Width of the web element’s bounding rectangle in CSS reference pixels.
Other elementState functions: getElementAttribute
,
getElementCssValue
,
getElementProperty
,
getElementTagName
,
getElementText
,
isElementEnabled
,
isElementSelected
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # select the search box searchElem <- remDr %>% findElement("name", "q") # get the name of our element searchElem %>% getElementAttribute("name") # get the css background-color searchElem %>% getElementCssValue("background-color") blueScript <- "arguments[0].style.backgroundColor = 'blue';" remDr %>% executeScript(blueScript, list(searchElem)) searchElem %>% getElementCssValue("background-color") # get the javascript property # searchElem %>% getElementProperty("backgroundColor") # get dimensions searchElem %>% getElementRect searchElem %>% getElementTagName # get some text and return it remDr %>% go("http://r-project.org") remDr %>% findElement("css", "h1") %>% getElementText # close browser remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # select the search box searchElem <- remDr %>% findElement("name", "q") # get the name of our element searchElem %>% getElementAttribute("name") # get the css background-color searchElem %>% getElementCssValue("background-color") blueScript <- "arguments[0].style.backgroundColor = 'blue';" remDr %>% executeScript(blueScript, list(searchElem)) searchElem %>% getElementCssValue("background-color") # get the javascript property # searchElem %>% getElementProperty("backgroundColor") # get dimensions searchElem %>% getElementRect searchElem %>% getElementTagName # get some text and return it remDr %>% go("http://r-project.org") remDr %>% findElement("css", "h1") %>% getElementText # close browser remDr %>% deleteSession ## End(Not run)
getElementTagName
Query for an element's tag name.
getElementTagName(webElem, ...)
getElementTagName(webElem, ...)
webElem |
An object of class "wElement". A web Element object see
|
... |
Additonal function arguments - Currently passes the
|
The element's tag name, as a lowercase character string.
Other elementState functions: getElementAttribute
,
getElementCssValue
,
getElementProperty
,
getElementRect
,
getElementText
,
isElementEnabled
,
isElementSelected
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # select the search box searchElem <- remDr %>% findElement("name", "q") # get the name of our element searchElem %>% getElementAttribute("name") # get the css background-color searchElem %>% getElementCssValue("background-color") blueScript <- "arguments[0].style.backgroundColor = 'blue';" remDr %>% executeScript(blueScript, list(searchElem)) searchElem %>% getElementCssValue("background-color") # get the javascript property # searchElem %>% getElementProperty("backgroundColor") # get dimensions searchElem %>% getElementRect searchElem %>% getElementTagName # get some text and return it remDr %>% go("http://r-project.org") remDr %>% findElement("css", "h1") %>% getElementText # close browser remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # select the search box searchElem <- remDr %>% findElement("name", "q") # get the name of our element searchElem %>% getElementAttribute("name") # get the css background-color searchElem %>% getElementCssValue("background-color") blueScript <- "arguments[0].style.backgroundColor = 'blue';" remDr %>% executeScript(blueScript, list(searchElem)) searchElem %>% getElementCssValue("background-color") # get the javascript property # searchElem %>% getElementProperty("backgroundColor") # get dimensions searchElem %>% getElementRect searchElem %>% getElementTagName # get some text and return it remDr %>% go("http://r-project.org") remDr %>% findElement("css", "h1") %>% getElementText # close browser remDr %>% deleteSession ## End(Not run)
getElementText
Returns the visible text for the element.
getElementText(webElem, ...)
getElementText(webElem, ...)
webElem |
An object of class "wElement". A web Element object see
|
... |
Additonal function arguments - Currently passes the
|
The visible text for an element is returned as a character string.
Other elementState functions: getElementAttribute
,
getElementCssValue
,
getElementProperty
,
getElementRect
,
getElementTagName
,
isElementEnabled
,
isElementSelected
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # select the search box searchElem <- remDr %>% findElement("name", "q") # get the name of our element searchElem %>% getElementAttribute("name") # get the css background-color searchElem %>% getElementCssValue("background-color") blueScript <- "arguments[0].style.backgroundColor = 'blue';" remDr %>% executeScript(blueScript, list(searchElem)) searchElem %>% getElementCssValue("background-color") # get the javascript property # searchElem %>% getElementProperty("backgroundColor") # get dimensions searchElem %>% getElementRect searchElem %>% getElementTagName # get some text and return it remDr %>% go("http://r-project.org") remDr %>% findElement("css", "h1") %>% getElementText # close browser remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # select the search box searchElem <- remDr %>% findElement("name", "q") # get the name of our element searchElem %>% getElementAttribute("name") # get the css background-color searchElem %>% getElementCssValue("background-color") blueScript <- "arguments[0].style.backgroundColor = 'blue';" remDr %>% executeScript(blueScript, list(searchElem)) searchElem %>% getElementCssValue("background-color") # get the javascript property # searchElem %>% getElementProperty("backgroundColor") # get dimensions searchElem %>% getElementRect searchElem %>% getElementTagName # get some text and return it remDr %>% go("http://r-project.org") remDr %>% findElement("css", "h1") %>% getElementText # close browser remDr %>% deleteSession ## End(Not run)
getNamedCookie
Get the cookie with a given name.
getNamedCookie(remDr, name = NULL, ...)
getNamedCookie(remDr, name = NULL, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
name |
character: The name of the cookie; may not be null or an empty string |
... |
Additonal function arguments - Currently passes the
|
A named cookies from the current domain is returned if it
exists. These cookies have values as stipulated by the arguments
given in addCookie
.
Other cookies functions: addCookie
,
deleteAllCookies
,
deleteCookie
, getAllCookies
## Not run: # assume a server is running at default location remDr <- remoteDr() remDr %>% go("https://www.google.com/ncr") %>% getTitle() # get the cookies remDr %>% getCookie() # get a named cookie remDr %>% getCookie("NID") # add our own cookie remDr %>% addCookie(name = "myCookie", value = "12") # check its value remDr %>% getCookie("myCookie") # delete our cookie remDr %>% deleteCookie("myCookie") # check its deleted remDr %>% getCookie("myCookie") # delete all cookies remDr %>% getCookie() remDr %>% deleteAllCookies() %>% getCookie() remDr %>% deleteSession() ## End(Not run)
## Not run: # assume a server is running at default location remDr <- remoteDr() remDr %>% go("https://www.google.com/ncr") %>% getTitle() # get the cookies remDr %>% getCookie() # get a named cookie remDr %>% getCookie("NID") # add our own cookie remDr %>% addCookie(name = "myCookie", value = "12") # check its value remDr %>% getCookie("myCookie") # delete our cookie remDr %>% deleteCookie("myCookie") # check its deleted remDr %>% getCookie("myCookie") # delete all cookies remDr %>% getCookie() remDr %>% deleteAllCookies() %>% getCookie() remDr %>% deleteSession() ## End(Not run)
getPageSource
Get the source of the last loaded page.
getPageSource(remDr, ...)
getPageSource(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
read_html(res$value): An xml document is returned.
The content from the remote webdriver is parsed (see
read_html
) and returned as xml.
Other documentHandling functions: executeAsyncScript
,
executeScript
## Not run: remDr <- remoteDr() # Get the page source remDr %>% go("https://www.google.com/ncr") %>% getPageSource remDr %>% getTitle() webElem <- remDr %>% findElement("css", "img#hplogo") # check if the logo is hidden remDr %>% executeScript("return document.getElementById('hplogo').hidden;", args = list()) # [1] FALSE # hide the logo remDr %>% executeScript("document.getElementById('hplogo').hidden = true;", args = list()) # Make the logo visible this time passing a web Element as an argument remDr %>% executeScript(script = "return arguments[0].hidden = false;", args = list(webElem)) # Pass arguments remDr %>% executeScript(script = "return argument[1] + argument[2];" , args = list(1, 2)) # Return a web Element remDr %>% executeScript( script = "return document.getElementById('hplogo');", args = list()) # ElementId: 0 # Remote Driver: # Remote Ip Address: http://localhost:4444/wd/hub # Remote sessionId: 9a83672a-d72b-4873-aa7d-96f7f1f80fa0 # Return a web Element in a more complex object script <- "var test ={num:1, str:'a', el:document.getElementById('hplogo')}; return test;" remDr %>% executeScript(script = script , args = list()) # $str # [1] "a" # # $num # [1] 1 # # $el # ElementId: 0 # Remote Driver: # Remote Ip Address: http://localhost:4444/wd/hub # Remote sessionId: 9a83672a-d72b-4873-aa7d-96f7f1f80fa0 # Run with replace = FALSE remDr %>% executeScript(script = script , args = list(), replace = FALSE) # $str # [1] "a" # # $num # [1] 1 # # $el # $el$ELEMENT # [1] "0" remDr %>% setTimeout("script") asScript <- "cb = arguments[0];setTimeout(function(){cb('DONE');},5000); " system.time(test1 <- remDr %>% executeAsyncScript(asScript, args = list())) sScript <- "setTimeout(function(){},5000); return 'DONE';" system.time(test2 <- remDr %>% executeScript(sScript, args = list())) remDr %>% deleteSession() ## End(Not run)
## Not run: remDr <- remoteDr() # Get the page source remDr %>% go("https://www.google.com/ncr") %>% getPageSource remDr %>% getTitle() webElem <- remDr %>% findElement("css", "img#hplogo") # check if the logo is hidden remDr %>% executeScript("return document.getElementById('hplogo').hidden;", args = list()) # [1] FALSE # hide the logo remDr %>% executeScript("document.getElementById('hplogo').hidden = true;", args = list()) # Make the logo visible this time passing a web Element as an argument remDr %>% executeScript(script = "return arguments[0].hidden = false;", args = list(webElem)) # Pass arguments remDr %>% executeScript(script = "return argument[1] + argument[2];" , args = list(1, 2)) # Return a web Element remDr %>% executeScript( script = "return document.getElementById('hplogo');", args = list()) # ElementId: 0 # Remote Driver: # Remote Ip Address: http://localhost:4444/wd/hub # Remote sessionId: 9a83672a-d72b-4873-aa7d-96f7f1f80fa0 # Return a web Element in a more complex object script <- "var test ={num:1, str:'a', el:document.getElementById('hplogo')}; return test;" remDr %>% executeScript(script = script , args = list()) # $str # [1] "a" # # $num # [1] 1 # # $el # ElementId: 0 # Remote Driver: # Remote Ip Address: http://localhost:4444/wd/hub # Remote sessionId: 9a83672a-d72b-4873-aa7d-96f7f1f80fa0 # Run with replace = FALSE remDr %>% executeScript(script = script , args = list(), replace = FALSE) # $str # [1] "a" # # $num # [1] 1 # # $el # $el$ELEMENT # [1] "0" remDr %>% setTimeout("script") asScript <- "cb = arguments[0];setTimeout(function(){cb('DONE');},5000); " system.time(test1 <- remDr %>% executeAsyncScript(asScript, args = list())) sScript <- "setTimeout(function(){},5000); return 'DONE';" system.time(test2 <- remDr %>% executeScript(sScript, args = list())) remDr %>% deleteSession() ## End(Not run)
getTimeouts
The Get Timeout command gets timeouts associated with
the current session.
getTimeouts(remDr, type = "page load", ...)
getTimeouts(remDr, type = "page load", ...)
remDr |
An object of class "rDriver". A remote driver object see
|
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. |
... |
Additonal function arguments - Currently passes the
|
ret2 : res$value NEED TO FILL IN specifics for each function
Other sessions functions: deleteSession
,
newSession
, setTimeouts
,
status
## Not run: # start a driver without opening a browser remDr <- remoteDr(newSession = FALSE) # open a broswer remDr %>% newSession # set timeout on waiting for elements remDr %>% setTimeout(type = "implicit", 5000) # close Session remDr %>% deleteSession ## End(Not run)
## Not run: # start a driver without opening a browser remDr <- remoteDr(newSession = FALSE) # open a broswer remDr %>% newSession # set timeout on waiting for elements remDr %>% setTimeout(type = "implicit", 5000) # close Session remDr %>% deleteSession ## End(Not run)
getTitle
Get the current page title.
getTitle(remDr, ...)
getTitle(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
The title of the current page is returned as a character string.
Other navigation functions: back
,
forward
, getCurrentUrl
,
go
, refresh
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # get the title remDr %>% getTitle # get the current page url remDr %>% getCurrentUrl # navigate remDr %>% go("http://www.bbc.co.uk") # go back remDr %>% (seleniumPipes::back) # go forward remDr %>% forward # refresh page remDr %>% refresh # close browser remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # get the title remDr %>% getTitle # get the current page url remDr %>% getCurrentUrl # navigate remDr %>% go("http://www.bbc.co.uk") # go back remDr %>% (seleniumPipes::back) # go forward remDr %>% forward # refresh page remDr %>% refresh # close browser remDr %>% deleteSession ## End(Not run)
getWindowHandle
Retrieve the current window handle.
getWindowHandle(remDr, ...)
getWindowHandle(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
Returns a string which is the "handle" for the current window.
Other commandContexts functions: closeWindow
,
fullscreenWindow
,
getWindowHandles
,
getWindowPosition
,
getWindowSize
,
maximizeWindow
,
setWindowPosition
,
setWindowSize
, switchToFrame
,
switchToParentFrame
,
switchToWindow
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
getWindowHandleOld
Retrieve the current window handle. Uses the
old JSONwireprotocol end points
getWindowHandleOld(remDr, ...)
getWindowHandleOld(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
Returns a string which is the "handle" for the current window.
Other oldMethods functions: acceptAlertOld
,
dismissAlertOld
,
executeAsyncScriptOld
,
executeScriptOld
,
getAlertTextOld
,
getWindowHandlesOld
,
getWindowPositionOld
,
getWindowSizeOld
,
maximizeWindowOld
,
sendAlertTextOld
,
setWindowPositionOld
,
setWindowSizeOld
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
getWindowHandles
Retrieve the list of all window handles available
to the session.
getWindowHandles(remDr, ...)
getWindowHandles(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
Returns a list of windows handles. Each element of the list is a string. The order window handles are returned is arbitrary.
Other commandContexts functions: closeWindow
,
fullscreenWindow
,
getWindowHandle
,
getWindowPosition
,
getWindowSize
,
maximizeWindow
,
setWindowPosition
,
setWindowSize
, switchToFrame
,
switchToParentFrame
,
switchToWindow
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
getWindowHandlesOld
Uses the old JSONwireprotocol end points.
Retrieve the list of all window handles available to the session.
getWindowHandlesOld(remDr, ...)
getWindowHandlesOld(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
Returns a list of windows handles. Each element of the list is a string. The order window handles are returned is arbitrary.
Other oldMethods functions: acceptAlertOld
,
dismissAlertOld
,
executeAsyncScriptOld
,
executeScriptOld
,
getAlertTextOld
,
getWindowHandleOld
,
getWindowPositionOld
,
getWindowSizeOld
,
maximizeWindowOld
,
sendAlertTextOld
,
setWindowPositionOld
,
setWindowSizeOld
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
getWindowPosition
The Get Window Position command returns the
position on the screen of the operating system window corresponding
to the current top-level browsing context.
getWindowPosition(remDr, ...)
getWindowPosition(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
Returns a list which contains the x coordinate to position the window at, relative to the upper left corner of the screen and the Y coordinate to position the window at, relative to the upper left corner of the screen
Other commandContexts functions: closeWindow
,
fullscreenWindow
,
getWindowHandles
,
getWindowHandle
,
getWindowSize
,
maximizeWindow
,
setWindowPosition
,
setWindowSize
, switchToFrame
,
switchToParentFrame
,
switchToWindow
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
getWindowPositionOld
Get the position of the specified window.
Uses the old JSONwireprotocol end points.
getWindowPositionOld(remDr, handle = "current", ...)
getWindowPositionOld(remDr, handle = "current", ...)
remDr |
An object of class "rDriver". A remote driver object see
|
handle |
Handle of the window to query. If handle = "current" (the default) the current window is used. |
... |
Additonal function arguments - Currently passes the
|
Returns a list which contains the x coordinate to position the window at, relative to the upper left corner of the screen and the Y coordinate to position the window at, relative to the upper left corner of the screen
Other oldMethods functions: acceptAlertOld
,
dismissAlertOld
,
executeAsyncScriptOld
,
executeScriptOld
,
getAlertTextOld
,
getWindowHandleOld
,
getWindowHandlesOld
,
getWindowSizeOld
,
maximizeWindowOld
,
sendAlertTextOld
,
setWindowPositionOld
,
setWindowSizeOld
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
getWindowSize
getWindowSize(remDr, ...)
getWindowSize(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
The width and height of the window are returned as elements in a list.
Other commandContexts functions: closeWindow
,
fullscreenWindow
,
getWindowHandles
,
getWindowHandle
,
getWindowPosition
,
maximizeWindow
,
setWindowPosition
,
setWindowSize
, switchToFrame
,
switchToParentFrame
,
switchToWindow
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
getWindowSizeOld
Get the size of the specified window. Uses the
old JSONwireprotocol end points.
getWindowSizeOld(remDr, handle = "current", ...)
getWindowSizeOld(remDr, handle = "current", ...)
remDr |
An object of class "rDriver". A remote driver object see
|
handle |
Handle of the window to query. If handle = "current" (the default) the current window is used. |
... |
Additonal function arguments - Currently passes the
|
The width and height of the window are returned as elements in a list.
Other oldMethods functions: acceptAlertOld
,
dismissAlertOld
,
executeAsyncScriptOld
,
executeScriptOld
,
getAlertTextOld
,
getWindowHandleOld
,
getWindowHandlesOld
,
getWindowPositionOld
,
maximizeWindowOld
,
sendAlertTextOld
,
setWindowPositionOld
,
setWindowSizeOld
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
go
Navigate to a new URL.
go(remDr, url, ...)
go(remDr, url, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
url |
The URL to navigate to. |
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other navigation functions: back
,
forward
, getCurrentUrl
,
getTitle
, refresh
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # get the title remDr %>% getTitle # get the current page url remDr %>% getCurrentUrl # navigate remDr %>% go("http://www.bbc.co.uk") # go back remDr %>% (seleniumPipes::back) # go forward remDr %>% forward # refresh page remDr %>% refresh # close browser remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # get the title remDr %>% getTitle # get the current page url remDr %>% getCurrentUrl # navigate remDr %>% go("http://www.bbc.co.uk") # go back remDr %>% (seleniumPipes::back) # go forward remDr %>% forward # refresh page remDr %>% refresh # close browser remDr %>% deleteSession ## End(Not run)
isElementEnabled
Determine if an element is currently enabled.
isElementEnabled(webElem, ...)
isElementEnabled(webElem, ...)
webElem |
An object of class "wElement". A web Element object see
|
... |
Additonal function arguments - Currently passes the
|
A logical value is returned indicating whether the elemnent is enabled.
Other elementState functions: getElementAttribute
,
getElementCssValue
,
getElementProperty
,
getElementRect
,
getElementTagName
,
getElementText
,
isElementSelected
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # select the search box searchElem <- remDr %>% findElement("name", "q") # get the name of our element searchElem %>% getElementAttribute("name") # get the css background-color searchElem %>% getElementCssValue("background-color") blueScript <- "arguments[0].style.backgroundColor = 'blue';" remDr %>% executeScript(blueScript, list(searchElem)) searchElem %>% getElementCssValue("background-color") # get the javascript property # searchElem %>% getElementProperty("backgroundColor") # get dimensions searchElem %>% getElementRect searchElem %>% getElementTagName # get some text and return it remDr %>% go("http://r-project.org") remDr %>% findElement("css", "h1") %>% getElementText # close browser remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # select the search box searchElem <- remDr %>% findElement("name", "q") # get the name of our element searchElem %>% getElementAttribute("name") # get the css background-color searchElem %>% getElementCssValue("background-color") blueScript <- "arguments[0].style.backgroundColor = 'blue';" remDr %>% executeScript(blueScript, list(searchElem)) searchElem %>% getElementCssValue("background-color") # get the javascript property # searchElem %>% getElementProperty("backgroundColor") # get dimensions searchElem %>% getElementRect searchElem %>% getElementTagName # get some text and return it remDr %>% go("http://r-project.org") remDr %>% findElement("css", "h1") %>% getElementText # close browser remDr %>% deleteSession ## End(Not run)
isElementSelected
Determines if an OPTION element, or an INPUT
element of type checkbox or radiobutton is currently selected.
isElementSelected(webElem, ...)
isElementSelected(webElem, ...)
webElem |
An object of class "wElement". A web Element object see
|
... |
Additonal function arguments - Currently passes the
|
A logical value is returned indicating whether the elemnent is selected.
Other elementState functions: getElementAttribute
,
getElementCssValue
,
getElementProperty
,
getElementRect
,
getElementTagName
,
getElementText
,
isElementEnabled
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # select the search box searchElem <- remDr %>% findElement("name", "q") # get the name of our element searchElem %>% getElementAttribute("name") # get the css background-color searchElem %>% getElementCssValue("background-color") blueScript <- "arguments[0].style.backgroundColor = 'blue';" remDr %>% executeScript(blueScript, list(searchElem)) searchElem %>% getElementCssValue("background-color") # get the javascript property # searchElem %>% getElementProperty("backgroundColor") # get dimensions searchElem %>% getElementRect searchElem %>% getElementTagName # get some text and return it remDr %>% go("http://r-project.org") remDr %>% findElement("css", "h1") %>% getElementText # close browser remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # select the search box searchElem <- remDr %>% findElement("name", "q") # get the name of our element searchElem %>% getElementAttribute("name") # get the css background-color searchElem %>% getElementCssValue("background-color") blueScript <- "arguments[0].style.backgroundColor = 'blue';" remDr %>% executeScript(blueScript, list(searchElem)) searchElem %>% getElementCssValue("background-color") # get the javascript property # searchElem %>% getElementProperty("backgroundColor") # get dimensions searchElem %>% getElementRect searchElem %>% getElementTagName # get some text and return it remDr %>% go("http://r-project.org") remDr %>% findElement("css", "h1") %>% getElementText # close browser remDr %>% deleteSession ## End(Not run)
maximizeWindow
Maximize the current if not already maximized.
maximizeWindow(remDr, ...)
maximizeWindow(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other commandContexts functions: closeWindow
,
fullscreenWindow
,
getWindowHandles
,
getWindowHandle
,
getWindowPosition
,
getWindowSize
,
setWindowPosition
,
setWindowSize
, switchToFrame
,
switchToParentFrame
,
switchToWindow
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
maximizeWindowOld
Maximize the specified window if not already
maximized.
maximizeWindowOld(remDr, handle = "current", ...)
maximizeWindowOld(remDr, handle = "current", ...)
remDr |
An object of class "rDriver". A remote driver object see
|
handle |
Handle of the window to query. If handle = "current" (the default) the current window is used. |
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other oldMethods functions: acceptAlertOld
,
dismissAlertOld
,
executeAsyncScriptOld
,
executeScriptOld
,
getAlertTextOld
,
getWindowHandleOld
,
getWindowHandlesOld
,
getWindowPositionOld
,
getWindowSizeOld
,
sendAlertTextOld
,
setWindowPositionOld
,
setWindowSizeOld
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
newSession
The server should attempt to create a session that
most closely matches the desired and required capabilities. Required
capabilities have higher priority than desired capabilities and must
be set for the session to be created.
newSession(remDr, ...)
newSession(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other sessions functions: deleteSession
,
getTimeouts
, setTimeouts
,
status
## Not run: # start a driver without opening a browser remDr <- remoteDr(newSession = FALSE) # open a broswer remDr %>% newSession # set timeout on waiting for elements remDr %>% setTimeout(type = "implicit", 5000) # close Session remDr %>% deleteSession ## End(Not run)
## Not run: # start a driver without opening a browser remDr <- remoteDr(newSession = FALSE) # open a broswer remDr %>% newSession # set timeout on waiting for elements remDr %>% setTimeout(type = "implicit", 5000) # close Session remDr %>% deleteSession ## End(Not run)
performActions
The Perform Actions command allows you to create
sequential interactions that can be sent over from the local end to
the remote end. This type of interactions allow emulations like drag
and drop.
performActions(remDr, ...)
performActions(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other interactions functions: releasingActions
## Not run: # functions not currently implemented ## End(Not run)
## Not run: # functions not currently implemented ## End(Not run)
queryDriver
A function to send a query to a remote driver.
Intended for seleniumPipes internal use mainly.
queryDriver(verb = GET, url, source, drvID, ...)
queryDriver(verb = GET, url, source, drvID, ...)
verb |
The http method to use. See |
url |
The url of the remote server endpoint. |
source |
The name of the seleniumPipes function that called queryDriver. |
drvID |
The driver id of the session as given by an object of class "remoteDr" |
... |
additonal arguments |
The contents of the response from the remote server. See
content
for details.
## Not run: # internal method ## End(Not run)
## Not run: # internal method ## End(Not run)
refresh
Refresh the current page.
refresh(remDr, ...)
refresh(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other navigation functions: back
,
forward
, getCurrentUrl
,
getTitle
, go
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # get the title remDr %>% getTitle # get the current page url remDr %>% getCurrentUrl # navigate remDr %>% go("http://www.bbc.co.uk") # go back remDr %>% (seleniumPipes::back) # go forward remDr %>% forward # refresh page remDr %>% refresh # close browser remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") # get the title remDr %>% getTitle # get the current page url remDr %>% getCurrentUrl # navigate remDr %>% go("http://www.bbc.co.uk") # go back remDr %>% (seleniumPipes::back) # go forward remDr %>% forward # refresh page remDr %>% refresh # close browser remDr %>% deleteSession ## End(Not run)
releasingActions
The Release Actions command is used to cancel
all current action chains. This is the equivalent of releasing all
modifiers from input sources.
releasingActions(remDr, ...)
releasingActions(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other interactions functions: performActions
## Not run: # functions not currently implemented ## End(Not run)
## Not run: # functions not currently implemented ## End(Not run)
remoteDr
: Create a remote Driver object
remoteDr(remoteServerAddr = "http://localhost", port = 4444L, browserName = "firefox", version = "", platform = "ANY", javascript = TRUE, nativeEvents = TRUE, extraCapabilities = list(), path = "wd/hub", newSession = TRUE, ...)
remoteDr(remoteServerAddr = "http://localhost", port = 4444L, browserName = "firefox", version = "", platform = "ANY", javascript = TRUE, nativeEvents = TRUE, extraCapabilities = list(), path = "wd/hub", newSession = TRUE, ...)
remoteServerAddr |
Object of class |
port |
Object of class |
browserName |
Object of class |
version |
Object of class |
platform |
Object of class |
javascript |
Object of class |
nativeEvents |
Object of class |
extraCapabilities |
A list containing any os/platform/driver specific arguments. |
path |
Path on the server side to issue webdriver calls to. Normally use the default value. |
newSession |
Logical value whether to start an instance of the
browser. If TRUE a browser will be opened using
|
... |
Pass addional arguments to newSession. Currently used to
pass |
An object of class "rDriver" is returned. This is a remote Driver object that is used in many of the remote driver specific functions. Many functions that take a remote driver object as input also return the remote driver object. This allows chaining of commands. See the examples for chaining in action.
## Not run: # assume a server is available at the default location. remDr <- remoteDr() remDR %>% go("http://www.google.com") %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") # close our browser remDr %>% deleteSession ## End(Not run)
## Not run: # assume a server is available at the default location. remDr <- remoteDr() remDR %>% go("http://www.google.com") %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") # close our browser remDr %>% deleteSession ## End(Not run)
The ability to retry
function code is enabled by default.
retry
can be a logical value. If it is TRUE then
noTry = getOption("seleniumPipes_no_try")
and
delay = getOption("seleniumPipes_no_try_delay")
. If it is
FALSE the facility to have multiple trys of the function call is
removed. retry
can also be a list with the following named
arguments that will override the values in options
Integer indicating how many times to try the function call
Integer indicating delay between trys of the function call
## Not run: remDr <- remoteDr() webElem <- remDr %>% go("http://www.google.com/ncr") %>% findElement("name", "q") # change the name of q with an 8 second delay myscript <- "var myElem = arguments[0]; window.setTimeout(function(){ myElem.setAttribute('name','funkyname'); }, 8000);" remDr %>% executeScript(myscript, args = list(webElem)) newWebElem <- remDr %>% findElement("name", "funkyname") # > newWebElem <- remDr %>% findElement("name", "funkyname") # # Calling findElement - Try no: 1 of 3 # # Calling findElement - Try no: 2 of 3 newWebElem %>% getElementAttribute("name") # compare with a function that will fail (no element present) rList <- list(noTry = 5, delay = 10) remDr %>% findElement("id", "i am not here", retry = rList) remDr %>% findElement("id", "i am not here", retry = FALSE) ## End(Not run)
## Not run: remDr <- remoteDr() webElem <- remDr %>% go("http://www.google.com/ncr") %>% findElement("name", "q") # change the name of q with an 8 second delay myscript <- "var myElem = arguments[0]; window.setTimeout(function(){ myElem.setAttribute('name','funkyname'); }, 8000);" remDr %>% executeScript(myscript, args = list(webElem)) newWebElem <- remDr %>% findElement("name", "funkyname") # > newWebElem <- remDr %>% findElement("name", "funkyname") # # Calling findElement - Try no: 1 of 3 # # Calling findElement - Try no: 2 of 3 newWebElem %>% getElementAttribute("name") # compare with a function that will fail (no element present) rList <- list(noTry = 5, delay = 10) remDr %>% findElement("id", "i am not here", retry = rList) remDr %>% findElement("id", "i am not here", retry = FALSE) ## End(Not run)
Implements the W3C webdriver specification.
seleniumPipes uses the following options
to configure
behaviour:
seleniumPipes_display_screenshot
: Logical value
indicating whether to display PNG returned by
takeScreenshot
and
takeElementScreenshot
. Defaults to TRUE
seleniumPipes_no_try
: An integer giving the number of
time to try calling an endpoint
on the Selenium Server. Defaults to 3 attempts
seleniumPipes_no_try_delay
: An integer detailing the
delay between attempts to call a failing endpoint on the Selenium
Server. Defaults to 5000 miliseconds = 5 seconds.
seleniumPipes_SL
: A logical value which acts as a flag
indicating whether SauiceLabs is being used for package testing.
seleniumPipes_selOptions
: A list used to store options
to pass to remoteDr
when running tests.
seleniumPipes_sauceID
: A character used to store remote
session ids when running SauceLab tests on the package.
This data set contains a list of selenium key mappings.
The key mappings are outlined at
https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#sessionsessionidelementidvalue.
selKeys is used when a sendKeys variable is needed. sendKeys is
defined as a list. If an entry is needed from selKeys it is denoted
by key.
selKeys
selKeys
A named list. The names are the descriptions of the keys. The values are the "UTF-8" character representations.
John Harrison, 2012-10-05
http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/value
sendAlertText
Send keystrokes to JavaScript prompt() dialog
sendAlertText(remDr, text = "", ...)
sendAlertText(remDr, text = "", ...)
remDr |
An object of class "rDriver". A remote driver object see
|
text |
A character vector of length 1. In other words a string. The text is passed to the JavaScript alert |
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other userPrompts functions: acceptAlert
,
dismissAlert
, getAlertText
## Not run: remDr <- remoteDr() remDr %>% go("https://www.google.com/ncr") %>% getTitle() sScript <- "setTimeout(function(){alert('HELLO')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% dismissAlert() sScript <- "setTimeout(function(){confirm('Press a button')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% acceptAlert() sScript <- "setTimeout(function(){confirm('Press a button')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% getAlertText() remDr %>% dismissAlert() sScript <- "setTimeout(function(){prompt('Please enter your name', '')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% getAlertText() remDr %>% sendAlertText("Buck Rogers?") remDr %>% deleteSession() ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("https://www.google.com/ncr") %>% getTitle() sScript <- "setTimeout(function(){alert('HELLO')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% dismissAlert() sScript <- "setTimeout(function(){confirm('Press a button')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% acceptAlert() sScript <- "setTimeout(function(){confirm('Press a button')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% getAlertText() remDr %>% dismissAlert() sScript <- "setTimeout(function(){prompt('Please enter your name', '')},1000); return 'DONE';" remDr %>% executeScript(sScript, args = list()) remDr %>% getAlertText() remDr %>% sendAlertText("Buck Rogers?") remDr %>% deleteSession() ## End(Not run)
sendAlertTextOld
Send keystrokes to JavaScript prompt() dialog.
This uses the old JSONwireprotocol endpoints.
sendAlertTextOld(remDr, text = "", ...)
sendAlertTextOld(remDr, text = "", ...)
remDr |
An object of class "rDriver". A remote driver object see
|
text |
A character vector of length 1. In other words a string. The text is passed to the JavaScript alert |
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other oldMethods functions: acceptAlertOld
,
dismissAlertOld
,
executeAsyncScriptOld
,
executeScriptOld
,
getAlertTextOld
,
getWindowHandleOld
,
getWindowHandlesOld
,
getWindowPositionOld
,
getWindowSizeOld
,
maximizeWindowOld
,
setWindowPositionOld
,
setWindowSizeOld
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
getTimeouts
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.
setTimeouts(remDr, type = "page load", milliseconds = 10000, ...)
setTimeouts(remDr, type = "page load", milliseconds = 10000, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
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. |
milliseconds |
The amount of time, in milliseconds, that time-limited commands are permitted to run. |
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other sessions functions: deleteSession
,
getTimeouts
, newSession
,
status
## Not run: # start a driver without opening a browser remDr <- remoteDr(newSession = FALSE) # open a broswer remDr %>% newSession # set timeout on waiting for elements remDr %>% setTimeout(type = "implicit", 5000) # close Session remDr %>% deleteSession ## End(Not run)
## Not run: # start a driver without opening a browser remDr <- remoteDr(newSession = FALSE) # open a broswer remDr %>% newSession # set timeout on waiting for elements remDr %>% setTimeout(type = "implicit", 5000) # close Session remDr %>% deleteSession ## End(Not run)
setWindowPosition
Change the position of the current window.
setWindowPosition(remDr, x, y, ...)
setWindowPosition(remDr, x, y, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
x |
integer The X coordinate to position the window at, relative to the upper left corner of the screen. |
y |
integer The Y coordinate to position the window at, relative to the upper left corner of the screen. |
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other commandContexts functions: closeWindow
,
fullscreenWindow
,
getWindowHandles
,
getWindowHandle
,
getWindowPosition
,
getWindowSize
,
maximizeWindow
,
setWindowSize
, switchToFrame
,
switchToParentFrame
,
switchToWindow
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
setWindowSize
Change the position of the specified window.
setWindowPositionOld(remDr, x, y, handle = "current", ...)
setWindowPositionOld(remDr, x, y, handle = "current", ...)
remDr |
An object of class "rDriver". A remote driver object see
|
x |
integer The X coordinate to position the window at, relative to the upper left corner of the screen. |
y |
integer The Y coordinate to position the window at, relative to the upper left corner of the screen. |
handle |
Handle of the window to query. If handle = "current" (the default) the current window is used. |
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other oldMethods functions: acceptAlertOld
,
dismissAlertOld
,
executeAsyncScriptOld
,
executeScriptOld
,
getAlertTextOld
,
getWindowHandleOld
,
getWindowHandlesOld
,
getWindowPositionOld
,
getWindowSizeOld
,
maximizeWindowOld
,
sendAlertTextOld
,
setWindowSizeOld
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
setWindowSize
Change the size of the current window.
setWindowSize(remDr, width, height, ...)
setWindowSize(remDr, width, height, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
width |
integer The new window width. |
height |
integer The new window height. |
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other commandContexts functions: closeWindow
,
fullscreenWindow
,
getWindowHandles
,
getWindowHandle
,
getWindowPosition
,
getWindowSize
,
maximizeWindow
,
setWindowPosition
,
switchToFrame
,
switchToParentFrame
,
switchToWindow
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
setWindowSize
Change the size of the specified window.
setWindowSizeOld(remDr, width, height, handle = "current", ...)
setWindowSizeOld(remDr, width, height, handle = "current", ...)
remDr |
An object of class "rDriver". A remote driver object see
|
width |
integer The new window width. |
height |
integer The new window height. |
handle |
Handle of the window to query. If handle = "current" (the default) the current window is used. |
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other oldMethods functions: acceptAlertOld
,
dismissAlertOld
,
executeAsyncScriptOld
,
executeScriptOld
,
getAlertTextOld
,
getWindowHandleOld
,
getWindowHandlesOld
,
getWindowPositionOld
,
getWindowSizeOld
,
maximizeWindowOld
,
sendAlertTextOld
,
setWindowPositionOld
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
## Not run: # functions in this group are using the old JSONwireprotocol end points ## End(Not run)
status
The Status command returns information about whether a
remote end is in a state in which it can create a new session.
This is represented by the ready property of the response body,
which has a value of false if attempting to create a session at
the current time would fail.
status(remDr, ...)
status(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
ret2 : res$value NEED TO FILL IN specifics for each function
Other sessions functions: deleteSession
,
getTimeouts
, newSession
,
setTimeouts
## Not run: # start a driver without opening a browser remDr <- remoteDr(newSession = FALSE) # open a broswer remDr %>% newSession # set timeout on waiting for elements remDr %>% setTimeout(type = "implicit", 5000) # close Session remDr %>% deleteSession ## End(Not run)
## Not run: # start a driver without opening a browser remDr <- remoteDr(newSession = FALSE) # open a broswer remDr %>% newSession # set timeout on waiting for elements remDr %>% setTimeout(type = "implicit", 5000) # close Session remDr %>% deleteSession ## End(Not run)
switchToFrame
Change focus to another frame on the page. If the
frame id is null, the server should switch to the page's default
content.
switchToFrame(remDr, Id = NULL, ...)
switchToFrame(remDr, Id = NULL, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
Id |
string|number|null|WebElement Identifier for the frame to change focus to. |
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other commandContexts functions: closeWindow
,
fullscreenWindow
,
getWindowHandles
,
getWindowHandle
,
getWindowPosition
,
getWindowSize
,
maximizeWindow
,
setWindowPosition
,
setWindowSize
,
switchToParentFrame
,
switchToWindow
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
switchToParentFrame
Change focus to the parent context. If the
current context is the top level browsing context, the context
remains unchanged.
switchToParentFrame(remDr, ...)
switchToParentFrame(remDr, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other commandContexts functions: closeWindow
,
fullscreenWindow
,
getWindowHandles
,
getWindowHandle
,
getWindowPosition
,
getWindowSize
,
maximizeWindow
,
setWindowPosition
,
setWindowSize
, switchToFrame
,
switchToWindow
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
switchToWindow
Change focus to another window.
switchToWindow(remDr, name, ...)
switchToWindow(remDr, name, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
name |
The handle of the window to change focus to. |
... |
Additonal function arguments - Currently passes the
|
invisible(remDr): An object of class "rDriver" is invisibly
returned. A remote driver object see remoteDr
. This
allows for chaining from this function to other functions that take
such an object as an argument. See examples for further details.
Other commandContexts functions: closeWindow
,
fullscreenWindow
,
getWindowHandles
,
getWindowHandle
,
getWindowPosition
,
getWindowSize
,
maximizeWindow
,
setWindowPosition
,
setWindowSize
, switchToFrame
,
switchToParentFrame
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% getWindowHandle() # The current window handle remDr %>% getWindowHandles() # All windows in the session # Get the window position remDr %>% getWindowPosition # Some browsers are still using the old JSON wire end points remDr %>% getWindowPositionOld # Get the size of the window remDr %>% getWindowSize # Some browsers are still using the old JSON wire end points # remDr %>% getWindowSizeOld # Set the window size remDr %>% setWindowSize(500, 500) # Some browsers are still using the old JSON wire end points remDr %>% setWindowSizeOld(500, 500) # Set the position of the window remDr %>% setWindowPositionOld(400, 100) # Some browsers are still using the old JSON wire end points # remDr %>% setWindowPositionOld(400, 100) # Maximise the window remDr %>% maximizeWindow # Some browsers are still using the old JSON wire end points # remDr %>% maximizeWindowold() remDr %>% go("http://www.google.com/ncr") # search for the "R project" remDr %>% findElement("name", "q") %>% elementSendKeys("R project", key = "enter") webElem <- remDr %>% findElement("css", "h3.r a") remDr %>% deleteSession ## End(Not run)
takeElementScreenshot
takeElementScreenshot(webElem, file = NULL, display = getOption("seleniumPipes_display_screenshot"), useViewer = !is.null(getOption("viewer")), returnPNG = FALSE, ...)
takeElementScreenshot(webElem, file = NULL, display = getOption("seleniumPipes_display_screenshot"), useViewer = !is.null(getOption("viewer")), returnPNG = FALSE, ...)
webElem |
An object of class "wElement". A web Element object see
|
file |
If not null the decoded PNG is written to file using the string provided here. Defaults to NULL. |
display |
logical Display the PNG or not (default is set in getOption("seleniumPipes_display_screenshot")). |
useViewer |
A viewer to view the PNG. Looks for the RSudio viewer by default. |
returnPNG |
logical return the decoded PNG. If false (default) webElem is returned to allow chaining. |
... |
Additonal function arguments - Currently passes the
|
If returnPNG
is FALSE the web Element object is returned
and additonal chaining is possible. If TRUE then the decoded base64
image is returned see base64_dec
Other screenCapture functions: takeScreenshot
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") remDr %>% takeScreenshot # select the search box searchElem <- remDr %>% findElement("name", "q") #searchElem %>% takeElementScreenshot() ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") remDr %>% takeScreenshot # select the search box searchElem <- remDr %>% findElement("name", "q") #searchElem %>% takeElementScreenshot() ## End(Not run)
takeScreenshot
takeScreenshot(remDr, file = NULL, display = getOption("seleniumPipes_display_screenshot"), useViewer = !is.null(getOption("viewer")), returnPNG = FALSE, ...)
takeScreenshot(remDr, file = NULL, display = getOption("seleniumPipes_display_screenshot"), useViewer = !is.null(getOption("viewer")), returnPNG = FALSE, ...)
remDr |
An object of class "rDriver". A remote driver object see
|
file |
If not null the decoded PNG is written to file using the string provided here. Defaults to NULL. |
display |
logical Display the PNG or not (default is set in getOption("seleniumPipes_display_screenshot")). |
useViewer |
A viewer to view the PNG. Looks for the RSudio viewer by default. |
returnPNG |
logical return the decoded PNG. If false (default) remDr is returned to allow chaining. |
... |
Additonal function arguments - Currently passes the
|
If returnPNG
is FALSE the remote Driver object is
returned and additonal chaining is possible. If TRUE then the
decoded base64 image is returned see base64_dec
Other screenCapture functions: takeElementScreenshot
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") remDr %>% takeScreenshot # select the search box searchElem <- remDr %>% findElement("name", "q") #searchElem %>% takeElementScreenshot() ## End(Not run)
## Not run: remDr <- remoteDr() remDr %>% go("http://www.google.com/ncr") remDr %>% takeScreenshot # select the search box searchElem <- remDr %>% findElement("name", "q") #searchElem %>% takeElementScreenshot() ## End(Not run)
wbElement
Create a Web Element object of class "wElement"
wbElement(elementId, remDr)
wbElement(elementId, remDr)
elementId |
This is a string returned by the web driver that identifies the web element. |
remDr |
An object of class "rDriver". A remote driver object see
|
An object of class "wElement" is returned. This is a web element object that is used in many of the web Element specific functions. Many functions that take a web Element object as input also return the web Element object. This allows chaining of commands. See the examples for chaining in action.
## Not run: remDr <- remoteDr() webElem <- remDR %>% go("http://www.google.com") %>% findElement("name", "q") # print the webElement webElem # send keys to the web Element webElem %>% elementSendKeys("R project", key = "enter") # close browser remDr %>% deleteSession() ## End(Not run)
## Not run: remDr <- remoteDr() webElem <- remDR %>% go("http://www.google.com") %>% findElement("name", "q") # print the webElement webElem # send keys to the web Element webElem %>% elementSendKeys("R project", key = "enter") # close browser remDr %>% deleteSession() ## End(Not run)