RSelenium issue with startServer() on windows - r

I just installed RSelenium from github (I have the same issue when I install it via cran) and I get the following error in windows machine:
Error in if (file.exists(file) == FALSE) if (!missing(asText) && asText == :
argument is of length zero
In addition: Warning message:
running command '"wmic" path win32_process get Caption,Processid,Commandline /format:htable' had status 44210
From the function startServer() this is the part that is producing the error:
system2("wmic", args = c("path win32_process get Caption,Processid,Commandline",
"/format:htable"), stdout = TRUE, stderr = NULL)
When I run this part I get the following:
character(0)
attr(,"status")
[1] 44210
Warning message:
running command '"wmic" path win32_process get Caption,Processid,Commandline /format:htable' had status 44210
My sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252 LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RSelenium_1.4.2 XML_3.98-1.4 RJSONIO_1.3-0 RCurl_1.95-4.8 bitops_1.0-6
loaded via a namespace (and not attached):
[1] httr_1.2.1 R6_2.1.2 tools_3.3.1 withr_1.0.1 curl_1.0 memoise_1.0.0 knitr_1.13 git2r_0.15.0
[9] caTools_1.17.1 digest_0.6.9 devtools_1.11.1

It is an issue with Win 7.
A htable XSL stylesheet is used to format the output of WMIC path win32_process
It results as a mismatch when using regional settings. Possible workarounds given are:
Copy or move the C:\Windows\system32\wbem\en-US*.xsl files up into the C:\Windows\system32\wbem\ folder.
Change your regional settings to match your Windows language version, log out and back in.
Specify the full path: WMIC process get /format:"%WINDIR%\System32\wbem\en-US\csv"
as noted in wmic error (invalid XSL format) in windows7

Related

How to access webpage from R

I am trying to access a webpage from R without any success -
> readLines('https://www.nseindia.com')
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") : InternetOpenUrl failed: 'The operation timed out'
Below is my session information-
> sessionInfo()
R version 4.0.1 (2020-06-06)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows Server x64 (build 17763)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] httr_1.4.1
loaded via a namespace (and not attached):
[1] compiler_4.0.1 R6_2.4.1 tools_4.0.1 curl_4.3
I am using R in Windows from Amazon AWS.
However when I use the same code from my local Mac, I have no problem.
Any pointer how to resolve this issue will be highly helpful.
Thanks,
setInternet2(TRUE)
Or try to run R in administrator mode.

RSelenium rsDriver peer SSL certificate issue

I am trying to learn using RSelenium. I am stuck with just trying to start the server using rsDriver. I am simply trying to run the code below and got the following error:
rD <- rsDriver()
checking Selenium Server versions:
BEGIN: PREDOWNLOAD
Error in open.connection(con, "rb") :
Peer certificate cannot be authenticated with given CA certificates
I searched around stack overflow and found out we can give options to rsDriver using below but I still got error:
my_extra <- list("--ignore-ssl-errors=true", "--ssl-protocol=tlsv1", "--web-security=no")
rs <- rsDriver(extraCapabilities = my_extra)
checking Selenium Server versions:
BEGIN: PREDOWNLOAD
Error in open.connection(con, "rb") :
Peer certificate cannot be authenticated with given CA certificates
Is there anything else I am missing?
for httr::GET function, I am able to bypass the SSL Certificate using:
set_config(config(ssl_verifypeer=0L)).
But this method does not work for RSelenium::rsDriver.
Here is my system spec:
My OS: Microsoft Windows 10
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RCurl_1.95-4.8 bitops_1.0-6 httr_1.2.1 wdman_0.2.2
[5] RSelenium_1.7.1
loaded via a namespace (and not attached):
[1] Rcpp_0.12.12 XML_3.98-1.9 binman_0.1.0 assertthat_0.2.0
[5] R6_2.2.2 jsonlite_1.5 semver_0.2.0 curl_2.7
[9] tools_3.4.1 yaml_2.1.14 compiler_3.4.1 caTools_1.17.1
[13] openssl_0.9.6
rsDriver uses the binman package to handle the downloading of relevant binaries. The selenium project lists its release in a JSON file at https://www.googleapis.com/storage/v1/b/selenium-release/o
You should have the same issue if you try:
jsonlite::fromJSON("https://www.googleapis.com/storage/v1/b/selenium-release/o")
You can mock the relevant curl fundtion using something like:
my_new_handle <- function(...){
print("mocking")
h <- .Call(curl:::R_new_handle, PACKAGE = "curl")
curl:::handle_setopt(h, ..., ssl_verifypeer = FALSE)
h
}
testthat::with_mock(
`curl::new_handle` = my_new_handle,
{
selCommand <- httr::with_config(config(ssl_verifypeer=0L),wdman::selenium(‌​retcommand=TRUE))
}
)

Why isn't it working when I attempt to open a firefox browser using rSelenium?

I am new to R and am trying to web scrape a jsp page to collect data. The page I want scrape from is: https://www.taxpayerservicecenter.com/RP_Search.jsp After I get a browser to open this url, I want to select neighborhoods, and scrape all the data there.
Also, is there an easier/better way to do this? This page has buttons and forms so it isn't as straight forward as say, scraping from a wikipedia page.
library(RSelenium) #passes
checkForServer() #passes
startServer() #passes
remDriver <- remoteDriver(remoteServerAddr="localhost", port=4444, browserName="firefox")
The following line is where I receive the error:
remDriver$open() #opens a browser, get the farthest w firefox
This is the error message I receive. I have searched everywhere for how to solve this!:
> remDriver$open() #opens a browser, get the farthest w firefox
[1] "Connecting to remote server"
Error: Summary: UnknownError
Detail: An unknown server-side error occurred while processing the command.
class: org.openqa.selenium.firefox.NotConnectedException
Things I have tried:
connecting to selenium server standalone by searching it and clicking on it
running the following: checkForServer(update = TRUE)
Here is my Session Info:
> sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RSelenium_1.3.5 XML_3.98-1.4 RJSONIO_1.3-0 RCurl_1.95-4.8 bitops_1.0-6
loaded via a namespace (and not attached):
[1] tools_3.3.0 caTools_1.17.1
Please, please, help!

Can not install shinyTable successfully

I followed the instruction on the Github. It returned me an error like this:
install_github("shinyTable", "trestletech")
Downloading github repo trestletech/shinyTable#master
Error in curl::curl_fetch_memory(url, handle = handle) :
Timeout was reached
In addition: Warning message:
Username parameter is deprecated. Please use trestletech/shinyTable
Then, I tried to download the repo zip file and installed the shinyTable from local zip file in R studio. After that, I library(shinyTable). It return me an error.
> install.packages("D:/UserData/xxxx/Downloads/shinyTable-master.zip", repos = NULL)
Installing package into ‘D:/UserData/xxxx/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
> library(shinyTable)
Error in library(shinyTable) : there is no package called ‘shinyTable’
This is sessionInfo() result:
R version 3.2.1 (2015-06-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shinyRGL_0.1.0 devtools_1.8.0 rJava_0.9-7
loaded via a namespace (and not attached):
[1] rgl_0.95.1247 Rcpp_0.12.0 digest_0.6.8 mime_0.3 R6_2.1.0 xtable_1.7-4 git2r_0.10.1
[8] magrittr_1.5 httr_1.0.0 stringi_0.5-5 curl_0.9.2 xml2_0.1.1 tools_3.2.1 stringr_1.0.0
[15] shiny_0.12.2 httpuv_1.3.3 rversions_1.0.2 htmltools_0.2.6 tcltk_3.2.1 memoise_0.2.1
Does anyone know the reason and tell me how to install it? Thank you.
I had similar issues recently. Can you try this:
library(devtools)
install_git("https://github.com/trestletech/shinyTable")

remDr$open() Unexpected Error when using RSelenium with phantomjs

I am using the following code
remDr <- remoteDriver(browserName = "phantomjs")
URL <-"http://www.soccer24.com/kosovo/superliga/results/#"
remDr$open()
I get the following error:
Error: Summary: UnknownError
Detail: An unknown server-side error occurred while processing the command.
class: java.lang.IllegalStateException
I don't know why am I getting the error?
My sessionInfo() result is below:
R version 3.0.3 (2014-03-06)
Platform: i386-w64-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] R Selenium_1.3.5 RJSONIO_1.3-0 XML_3.98-1.1 RCurl_1.95-4.5 bitops_1.0-6
loaded via a namespace (and not attached):
[1] caTools_1.17.1 tools_3.0.3
And my java version is provided below for your reference:
system("java -version")
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) Client VM (build 24.55-b03, mixed mode, sharing)
It looks like you don't currently have the phantomjs.exe on your path. More details can be found in the RSelenium "Saucelabs" vignette http://cran.r-project.org/web/packages/RSelenium/vignettes/RSelenium-saucelabs.html#id2a.
So download phantomjs from here: http://phantomjs.org/download.html and put the exe in your path.

Resources