Setting proxy in RSelenium with PhantomJS

北战南征 提交于 2019-12-12 09:48:20

问题


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?


回答1:


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()


来源:https://stackoverflow.com/questions/29656217/setting-proxy-in-rselenium-with-phantomjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!