Maybe my question is a little basic, but know very little programming. I'm trying to automate the downloading of data from the next page (it is a page of the Chilean government, so the data are public) With the package Rselenium
I learned a little about selecting items and clicking a few. But I do not know how to address a drop-down list
RSelenium::checkForServer()
RSelenium::startServer(args = c("-port 4455"),
log = FALSE, invisible = FALSE)
# RSelenium::startServer() if required
require(RSelenium)
remDr <- remoteDriver(remoteServerAddr = "localhost"
, port = 4444
, browserName = "chrome"
)
remDr$open()
remDr$getStatus()
remDr$getCurrentUrl()
remDr$refresh()
remDr$navigate("http://apps.odepa.cl/SeriesHistoricasParams")
table <- remDr$findElement(using='id', value="table")
remDr$switchToFrame(table)
option <- remDr$findElement(using = 'xpath', "//*/option[@value = '01']")
If anyone could help me select options from the drop-down lists that appear, it would be appreciated. Please be clear, I understand very little programming, I use R for statistical analysis.
Update
I could select the first item in the list and select OK. My problem, the rest of the list has the same names "selector40" so I do not know how to identify them correctly. I think I should edit the section of the code
"//*/option[@value = '01']"
But I do not know how
Here my sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.4 LTS
locale:
[1] LC_CTYPE=es_CL.UTF-8
[2] LC_NUMERIC=C
[3] LC_TIME=es_CL.UTF-8
[4] LC_COLLATE=es_CL.UTF-8
[5] LC_MONETARY=es_CL.UTF-8
[6] LC_MESSAGES=es_CL.UTF-8
[7] LC_PAPER=es_CL.UTF-8
[8] LC_NAME=C
[9] LC_ADDRESS=C
[10] LC_TELEPHONE=C
[11] LC_MEASUREMENT=es_CL.UTF-8
[12] LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils
[5] datasets methods base
loaded via a namespace (and not attached):
[1] rsconnect_0.4.3 tools_3.3.1
> library(RSelenium)
Loading required package: RCurl
Loading required package: bitops
Loading required package: RJSONIO
Loading required package: XML
> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.4 LTS
locale:
[1] LC_CTYPE=es_CL.UTF-8
[2] LC_NUMERIC=C
[3] LC_TIME=es_CL.UTF-8
[4] LC_COLLATE=es_CL.UTF-8
[5] LC_MONETARY=es_CL.UTF-8
[6] LC_MESSAGES=es_CL.UTF-8
[7] LC_PAPER=es_CL.UTF-8
[8] LC_NAME=C
[9] LC_ADDRESS=C
[10] LC_TELEPHONE=C
[11] LC_MEASUREMENT=es_CL.UTF-8
[12] LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils
[5] datasets methods base
other attached packages:
[1] RSelenium_1.3.5 XML_3.98-1.4 RJSONIO_1.3-0
[4] RCurl_1.95-4.8 bitops_1.0-6
loaded via a namespace (and not attached):
[1] rsconnect_0.4.3 tools_3.3.1 caTools_1.17.1