Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RSelenium behind proxy

I am trying to use RSelenium. Here is what I am doing:

library(RSelenium)  
driver<- rsDriver(browser=c("chrome"))
remDr <- driver[["client"]]
remDr$open()

returns
$id
[1] NA

remDr$navigate("http://www.google.com")

(returns NULL)

remDr$getCurrentUrl()

returns empty list

I am thinking this disappointing result might be because I am behind corporate proxy.

How can I pass the http proxy to selenium browser?

Thank you

like image 902
RockScience Avatar asked May 17 '18 09:05

RockScience


1 Answers

You need to use extraCapabilities and set the proxy using the same

cprof <- list(chromeOptions = 
                  list(args = list("--proxy-server=http://118.69.61.212:53281")))

driver<- rsDriver(browser=c("chrome"), extraCapabilities = cprof)
driver$client$navigate("http://ipinfo.io")

And you can see that chrome now uses the proxy config

Chrome proxy

like image 162
Tarun Lalwani Avatar answered Nov 13 '22 23:11

Tarun Lalwani