Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved wdman and binman to Suggests #177

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ before_install:
- svn checkout https://github.com/SeleniumHQ/selenium/trunk/common/src/web
- docker run -d -p 3000:8080 --name http-server -v $(pwd)/web:/public redsadic/docker-http-server&
- docker run -d -p 127.0.0.1:4444:4444 --link http-server selenium/standalone-chrome:2.53.1
r_github_packages:
- johndharrison/binman
- johndharrison/wdman
r:
- oldrel
- release
Expand Down
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ Depends:
Imports:
XML,methods,caTools,tools,utils,
openssl,
httr,
wdman(>= 0.2.2),
binman
httr
Suggests:
testthat,
knitr,
Rcompression,
covr,
rmarkdown
rmarkdown,
wdman(>= 0.2.2),
binman
VignetteBuilder: knitr
LazyData: true
Collate:
Expand Down
4 changes: 0 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export(errorHandler)
export(getChromeProfile)
export(getFirefoxProfile)
export(makeFirefoxProfile)
export(phantom)
export(remoteDriver)
export(rsDriver)
export(selKeys)
Expand All @@ -27,11 +26,8 @@ importFrom(caTools,base64encode)
importFrom(methods,new)
importFrom(methods,setRefClass)
importFrom(openssl,base64_decode)
importFrom(tools,pskill)
importFrom(utils,.DollarNames)
importFrom(utils,download.file)
importFrom(utils,head)
importFrom(utils,read.csv)
importFrom(utils,tail)
importFrom(utils,zip)
importFrom(wdman,selenium)
15 changes: 12 additions & 3 deletions R/rsDriver.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' @param browser Which browser to start
#' @param version what version of Selenium Server to run. Default = "latest"
#' which runs the most recent version. To see other version currently
#' sourced run binman::list_versions("seleniumserver")
#' sourced run binman::list_versions("seleniumserver").
#' @param chromever what version of Chrome driver to run. Default = "latest"
#' which runs the most recent version. To see other version currently
#' sourced run binman::list_versions("chromedriver"), A value of NULL
Expand Down Expand Up @@ -36,9 +36,12 @@
#' Windows. For a more detailed set of functions for running binaries
#' relating to the Selenium/webdriver project see the
#' \code{\link[wdman]{wdman}} package. Both the client and server
#' are closed using a registered finalizer.
#' are closed using a registered finalizer.
#'
#' The package binman is currently unavailable from CRAN but can be
#' installed using, for example,
#' \code{devtools::install_github("johndharrison/binman")}.
#' @export
#' @importFrom wdman selenium
#'
#' @examples
#' \dontrun{
Expand Down Expand Up @@ -72,6 +75,12 @@ rsDriver <- function(port = 4567L,
!identical(.Platform[["OS.type"]], "windows")){
stop("Internet Explorer is only available on Windows.")
}
if (!requireNamespace("wdman", quietly = TRUE)) {
stop("Package \"wdman\" is needed for this function to ",
"work. Please install it (e.g. using \"devtools::",
"install_github(\"johndharrison/wdman\")\".",
call. = FALSE)
}
selServ <- wdman::selenium(port = port, verbose = verbose,
version = version,
chromever = chromever,
Expand Down
89 changes: 0 additions & 89 deletions R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -177,95 +177,6 @@ getChromeProfile <- function(dataDir, profileDir){
cprof
}

#' Start a phantomjs binary in webdriver mode.
#'
#' \code{phantom}
#' A utility function to control a phantomjs binary in webdriver mode.
#' @param pjs_cmd The name, full or partial path of a phantomjs
#' executable. This is optional only state if the executable is not in
#' your path.
#' @param port An integer giving the port on which phantomjs will listen.
#' Defaults to 4444. format [[<IP>:]<PORT>]
#' @param extras An optional character vector: see 'Details'.
#' @param ... Arguments to pass to \code{\link{system2}}
#' @export
#' @importFrom tools pskill
#' @importFrom utils read.csv
#' @section Detail: phantom() is used to start a phantomjs binary in
#' webdriver mode. This can be used to drive a phantomjs binary on a
#' machine without selenium server. Argument extras can be used to
#' specify optional extra command line arguments see
#' \url{http://phantomjs.org/api/command-line.html}
#' @section Value: phantom() returns a list with two functions:
#' \describe{
#' \item{getPID}{returns the process id of the phantomjs binary running in
#' webdriver mode.}
#' \item{stop}{terminates the phantomjs binary running in webdriver mode
#' using \code{\link{pskill}}}
#' }
#' @examples
#' \dontrun{
#' pJS <- phantom()
#' # note we are running here without a selenium server phantomjs is
#' # listening on port 4444
#' # in webdriver mode
#' remDr <- remoteDriver(browserName = "phantomjs")
#' remDr$open()
#' remDr$navigate("http://www.google.com/ncr")
#' remDr$screenshot(display = TRUE)
#' webElem <- remDr$findElement("name", "q")
#' webElem$sendKeysToElement(list("HELLO WORLD"))
#' remDr$screenshot(display = TRUE)
#' remDr$close()
#' # note remDr$closeServer() is not called here. We stop the phantomjs
#' # binary using
#' pJS$stop()
#' }

phantom <- function (pjs_cmd = "", port = 4444L, extras = "", ...){
.Deprecated(new = "phantomjs", package = "wdman",
msg = "The phantom function in RSelenium
is now deprecated and will be defunct in future releases.
Users can drive PhantomJS via selenium using the RSelenium::rsDriver
function or directly using wdman::phantomjs")
if (!nzchar(pjs_cmd)) {
pjsPath <- Sys.which("phantomjs")
}else{
pjsPath <- pjs_cmd
}
if(nchar(pjsPath) == 0){stop("PhantomJS binary not located.")}
pjsargs <- c(paste0("--webdriver=", port), extras)
if (.Platform$OS.type == "windows"){
system2(pjsPath, pjsargs, invisible = TRUE, wait = FALSE, ...)
pjsPID <- read.csv(text = system("tasklist /v /fo csv", intern = TRUE))
# support for MS-DOS-compatible (short) file name
pjsPID <- pjsPID$PID[grepl("phantomjs.exe|PHANTO~1.EXE",
pjsPID$Image.Name)]
}else{
system2(pjsPath, pjsargs, wait = FALSE, ...)
if(Sys.info()["sysname"] == "Darwin"){
pids <- system('ps -Ao"pid"', intern = TRUE)
args <- system('ps -Ao"args"', intern = TRUE)
}else{
pids <- system('ps -Ao"%p"', intern = TRUE)
args <- system('ps -Ao"%a"', intern = TRUE)
}
idx <- grepl("phantomjs", args)
if(!any(idx)) warning("Couldn't find the phantomjs process")
pjsPID <- pids[idx]
}

list(
stop = function(){
tools::pskill(pjsPID)
},
getPID = function(){
return(pjsPID)
}
)
}


matchSelKeys <- function(x){
if(any(names(x) =='key')){
x[names(x) =='key']<-selKeys[match(x[names(x) == 'key'],names(selKeys))]
Expand Down
2 changes: 2 additions & 0 deletions man/errorHandler-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 0 additions & 61 deletions man/phantom.Rd

This file was deleted.

6 changes: 5 additions & 1 deletion man/rsDriver.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.