JoeArtisan
JoeArtisan

Reputation: 145

Setting proxy in RSelenium with PhantomJS

I'm using the RSelenium library with the argument browserName = "phantomjs" in the remoteDriver command, however I was looking to run a test where I specify the type of the proxy server. I've seen that proxy authentication is possible in, e.g. Java, with the code used shown here:

ArrayList<String> cliArgsCap = new ArrayList<String>();
cliArgsCap.add("--proxy=address:port");
cliArgsCap.add("--proxy-auth=username:password");
cliArgsCap.add("--proxy-type=http");
DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
capabilities.setCapability(
PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgsCap);
WebDriver driver = new PhantomJSDriver(capabilities);

Can the above be replicated in R?

Upvotes: 3

Views: 1766

Answers (1)

jdharrison
jdharrison

Reputation: 30435

The following should work:

library(RSelenium)
pJS <- phantom(extras = c("--proxy=192.168.1.42:8080")
                           , "--proxy-auth=username:password"
                           , "--proxy-type=http")
)
remDr <- remoteDriver(browserName = "phantomjs")
remDr$open()

Upvotes: 2

Related Questions