0

I am trying to repeat the example code shown in the RSelenium remoteDriver help topic. As you can see from the commented out responses I am getting a redirection, and I get the same response for every RSelenium function. How do I overcome this problem?

startServer()
remDr <- remoteDriver$new()
remDr$open()
# [1] "Connecting to remote server"
# [[1]]
# [1] "<HTML>\r\n<HEAD><TITLE>Redirection</TITLE></HEAD>\r\n<BODY><H1>Redirect</H1></BODY>\r\n"
# 
# $id
# [1] NA

remDr$navigate("http://www.r-project.org")
remDr$getPageSource()
# [[1]]
# [1] "<HTML>\r\n<HEAD><TITLE>Redirection</TITLE></HEAD>\r\n<BODY><H1>Redirect</H1></BODY>\r\n"
# remDr$findElements(value = "//frame")
# [[1]]
# [1] "remoteDriver fields"
# $remoteServerAddr
# [1] "localhost"
# 
# $port
# [1] 4444
# 
# $browserName
# [1] "firefox"
# 
# $version
# [1] ""
# 
# $platform
# [1] "ANY"
# 
# $javascript
# [1] TRUE
# 
# $autoClose
# [1] FALSE
# 
# $nativeEvents
# [1] TRUE
# 
# $extraCapabilities
# list()
# 
# [1] "webElement fields"
# $elementId
# [1] "<HTML>\r\n<HEAD><TITLE>Redirection</TITLE></HEAD>\r\n<BODY><H1>Redirect</H1></BODY>\r\n"

I am working on a corporate-supplied laptop behind a proxy firewall. This is how I change the proxy to successfully access the web when I use the httr or rvest packages:

set_config(use_proxy(url = "http://proxy-server.mycompany.com:8080"))

Any suggestions?

hackR
  • 1,459
  • 17
  • 26

1 Answers1

2

The proxy information needs to be passed as a list via extraCapabilities. The documentation on the form a proxy takes is given here.

extraCapabilities <- list(proxy = list(proxyType = "manual"
                                       , httpProxy = "http://proxy-server.mycompany.com:8080")
                          )
remDr <- remoteDriver(extraCapabilities = extraCapabilities)
jdharrison
  • 30,085
  • 4
  • 77
  • 89
  • Thanks for the suggestion. Unfortunately I tried this and I still get a response of `[[1]] [1] "\r\nRedirection\r\n

    Redirect

    \r\n"` after the command `remDr$open()`. I have also tried lots of variations of the proxy url, and also `extraCapabilities <- list(proxy = list(proxyType = "pac", proxyAutoconfigUrl = "http://aaa-server/aaa/proxy.pac"))` using a PAC method, all without success. Any other suggestions?
    – hackR Jul 18 '16 at 18:43
  • Is it http or https. If the latter you will need to set sslProxy rather than httpProxy. This is the way to do it. It is just a question of getting the structure correct. – jdharrison Jul 18 '16 at 19:55
  • How can I tell if the Selenium server is running? After running this: `RSelenium::startServer()` there is no response inside R. And if I look into the Windows Task Manager, there is no obvious Windows process running ... – hackR Jul 18 '16 at 21:50