RSelenium
RSelenium copied to clipboard
phantomExecute always returns Error in resContent[["status"]] : subscript out of bounds
Whenever, I try to run the simplest javascript through
remDr$phantomExecute
I always get the same error
Error in resContent[["status"]] : subscript out of bounds
From the beginning of the example of ( near the bottom of the HTML page )
PhantomJS writing to file
https://cran.r-project.org/web/packages/RSelenium/vignettes/RSelenium-headless.html
library(RSelenium)
pJS <- phantom()
# Warning: 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
# [INFO - 2018-04-08T22:04:49.518Z] GhostDriver - Main - running on port 4444
remDr <- remoteDriver(browserName = "phantom")
remDr$open()
# [1] "Connecting to remote server"
# [INFO - 2018-04-08T22:04:54.556Z] Session [de3cc900-3b78-11e8-a262-0fdb6508725e] - page.settings - {"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent":"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1","webSecurityEnabled":true}
# [INFO - 2018-04-08T22:04:54.585Z] Session [de3cc900-3b78-11e8-a262-0fdb6508725e] - page.customHeaders: - {}
# [INFO - 2018-04-08T22:04:54.589Z] Session [de3cc900-3b78-11e8-a262-0fdb6508725e] - Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"2.1.1","driverName":"ghostdriver","driverVersion":"1.2.0","platform":"windows-10-32bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
# [INFO - 2018-04-08T22:04:54.609Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: de3cc900-3b78-11e8-a262-0fdb6508725e
# $browserName
# [1] "phantomjs"
#
# $version
# [1] "2.1.1"
#
# $driverName
# [1] "ghostdriver"
#
# $driverVersion
# [1] "1.2.0"
#
# $platform
# [1] "windows-10-32bit"
#
# $javascriptEnabled
# [1] TRUE
#
# $takesScreenshot
# [1] TRUE
#
# $handlesAlerts
# [1] FALSE
#
# $databaseEnabled
# [1] FALSE
#
# $locationContextEnabled
# [1] FALSE
#
# $applicationCacheEnabled
# [1] FALSE
#
# $browserConnectionEnabled
# [1] FALSE
#
# $cssSelectorsEnabled
# [1] TRUE
#
# $webStorageEnabled
# [1] FALSE
#
# $rotatable
# [1] FALSE
#
# $acceptSslCerts
# [1] FALSE
#
# $nativeEvents
# [1] TRUE
#
# $proxy
# $proxy$proxyType
# [1] "direct"
#
#
# $id
# [1] "de3cc900-3b78-11e8-a262-0fdb6508725e"
result <- remDr$phantomExecute("var page = this;") ## ALWAYS AND ERROR HERE
# [ERROR - 2018-04-08T22:09:03.900Z] RouterReqHand - _handle.error - {"name":"Missing Command Parameter","message":"{\"headers\":{\"Accept\":\"application/json, text/xml, application/xml, */*\",\"Accept-Encoding\":\"gzip, deflate\",\"Content-Length\":\"29\",\"Content-Type\":\"application/json\",\"Host\":\"localhost:4444\",\"User-Agent\":\"libcurl/7.59.0 r-curl/3.2 httr/1.3.1\"},\"httpVersion\":\"1.1\",\"method\":\"POST\",\"post\":\"{\\\"script\\\":\\\"var page = this;\\\"}\",\"url\":\"/phantom/execute\",\"urlParsed\":{\"anchor\":\"\",\"query\":\"\",\"file\":\"execute\",\"directory\":\"/phantom/\",\"path\":\"/phantom/execute\",\"relative\":\"/phantom/execute\",\"port\":\"\",\"host\":\"\",\"password\":\"\",\"user\":\"\",\"userInfo\":\"\",\"authority\":\"\",\"protocol\":\"\",\"source\":\"/phantom/execute\",\"queryKey\":{},\"chunks\":[\"phantom\",\"execute\"]},\"urlOriginal\":\"/session/de3cc900-3b78-11e8-a262-0fdb6508725e/phantom/execute\"}","line":865,"sourceURL":"phantomjs://code/session_request_handler.js","stack":"_executePhantomJS@phantomjs://code/session_request_handler.js:865:73\n_handle@phantomjs://code/session_request_handler.js:166:30\n_reroute@phantomjs://code/request_handler.js:61:20\n_handle@phantomjs://code/router_request_handler.js:78:46"}
#
# phantomjs://platform/console++.js:263 in error
# No encoding supplied: defaulting to UTF-8.
# Error in resContent[["status"]] : subscript out of bounds
phantomjs-2.1.1-windows.zip (17.4 MB)
http://phantomjs.org/download.html
> devtools::session_info()
Session info ------------------------------------------------------------------
setting value
version R version 3.4.4 (2018-03-15)
system x86_64, mingw32
ui RTerm
language (EN)
collate English_United States.1252
tz America/Chicago
date 2018-04-08
Packages ----------------------------------------------------------------------
package * version date source
assertthat 0.2.0 2017-04-11 CRAN (R 3.4.0)
base * 3.4.4 2018-03-15 local
binman 0.1.0 2017-01-14 CRAN (R 3.4.3)
bitops 1.0-6 2013-08-17 CRAN (R 3.4.0)
caTools 1.17.1 2014-09-10 CRAN (R 3.4.0)
compiler 3.4.4 2018-03-15 local
datasets * 3.4.4 2018-03-15 local
devtools 1.13.5 2018-02-18 CRAN (R 3.4.3)
digest 0.6.15 2018-01-28 CRAN (R 3.4.3)
graphics * 3.4.4 2018-03-15 local
grDevices * 3.4.4 2018-03-15 local
magrittr * 1.5 2014-11-22 CRAN (R 3.4.0)
memoise 1.1.0 2017-04-21 CRAN (R 3.4.0)
methods * 3.4.4 2018-03-15 local
openssl 1.0.1 2018-03-03 CRAN (R 3.4.3)
Rcpp 0.12.16 2018-03-13 CRAN (R 3.4.3)
RSelenium * 1.7.1 2017-01-24 CRAN (R 3.4.4)
semver 0.2.0 2017-01-06 CRAN (R 3.4.4)
stats * 3.4.4 2018-03-15 local
tools 3.4.4 2018-03-15 local
utils * 3.4.4 2018-03-15 local
wdman 0.2.2 2017-01-23 CRAN (R 3.4.3)
withr 2.1.2 2018-03-23 Github (jimhester/withr@79d7b0d)
XML 3.98-1.10 2018-02-19 CRAN (R 3.4.3)
>
I am having the exact same issue. Has a solution already been found?
Ok, did some more investigation. Apparently you need to provide a list with at least one element for the args argument of phantomExecute. So, for example:
result <- remDr$phantomExecute("var page = this;", list(""))
I think this is a bug that needs to be fixed.