16

I found this fantastic answer by @jdharrison on how to launch Tor using RSelenium on windows: https://stackoverflow.com/a/39048970/7837376

In the new version of RSelenium, however, startServer() is defunct and its replacement rsDriver() does not take a java argument as startServer() did before.

What is the way to launch Tor as above in firefox in the new RSelenium syntax? Thanks very much (in advance)!

Neal Barsch
  • 2,810
  • 2
  • 13
  • 39
  • Doesn't this work? https://github.com/ropensci/RSelenium/issues/156#issuecomment-346425906 – Tarun Lalwani Jun 16 '18 at 04:45
  • I had seen this in the issues, but had glossed over it. Let me check it out, looking at it closer it is worth a try that way for sure. Thanks for the help Tarun! – Neal Barsch Jun 16 '18 at 04:51
  • 1
    No worries, check the answer I just posted, I think that should do the job, though you may need to have some wait between launching the server and opening the driver to make sure selenium server is up. See this https://github.com/ropensci/RSelenium/blob/8667b1ab7074ee535588d8182ea61f8e698fd54b/R/rsDriver.R#L85 – Tarun Lalwani Jun 16 '18 at 05:05
  • Thanks for your help, I am so close (and happy to award the 50 points if I can get it!) Like possibly how long? I tried this and it has been busy for 10 mins. I tried launching via ```selServ <- wdman::selenium(retcommand = FALSE, port = 4567L, check = FALSE, geckover = "0.19.1") rD <- rsDriver(browser = "firefox", port = 4567L, extraCapabilities = list( `moz:firefoxOptions` = list( binary = "C:/Users/Administrator/Desktop/Tor Browser/Browser/firefox.exe" # FF v56.0.2 x64 ) ))``` – Neal Barsch Jun 16 '18 at 05:35
  • 1
    What about the code I posted in the answer? That doesn't use `moz:firefoxOptions` and probably doesn't need it also – Tarun Lalwani Jun 16 '18 at 06:14
  • See my comment there. So close it's tantalizing! – Neal Barsch Jun 16 '18 at 06:30

1 Answers1

1

You can start the selenium server yourself instead of using rsDriver

browserP <- "C:/Users/john/Desktop/Tor Browser/Browser/firefox.exe"
jArg <- paste0("-Dwebdriver.firefox.bin=\"", browserP, "\"")
pLoc <- "C:/Users/john/Desktop/Tor Browser/Browser/TorBrowser/Data/Browser/profile.meek-http-helper/"
jArg <- c(jArg, paste0("-Dwebdriver.firefox.profile=\"", pLoc, "\""))

wdman::selenium(jvmargs=jArg, selargs='any selenium args')
remDr <- remoteDriver(browserName ="firefox", port=4567L)
driver <- remDr$open()
Tarun Lalwani
  • 142,312
  • 9
  • 204
  • 265
  • Just to consolidate, I still get ```Selenium message:Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line``` running yours directly. By adding ```remDr <- remoteDriver(browserName = "firefox", port = 4567L, extraCapabilities = list( `moz:firefoxOptions` = list( binary = "C:/Users/Administrator/Desktop/Tor Browser/Browser/firefox.exe" ) ))``` I still get error ```Selenium message:connection refused``` – Neal Barsch Jun 16 '18 at 06:20
  • 1
    Okie let me try the example again, I don't have windows but I assume Mac also would be the same – Tarun Lalwani Jun 16 '18 at 06:49
  • No ideas? Its so close, it's launching it, just not connecting to the browser. I think I need some proxy settings. I'll mess with it tomorrow. – Neal Barsch Jun 17 '18 at 09:14
  • 1
    @NealBarsch, yeah I tried, same issue the browser launches well but i guess the connection between `marionette` server and the `geckodriver` doesn't happen. This needs more debugging time, which I am afraid I don't have right now. – Tarun Lalwani Jun 17 '18 at 09:17