1

I want to use RSelenium for web scraping, but ran into this problem when trying to connect to Firefox. Would appreciate any help.

 > rD <- rsDriver(browser = "firefox")
    checking Selenium Server versions:
    BEGIN: PREDOWNLOAD
    BEGIN: DOWNLOAD
    BEGIN: POSTDOWNLOAD
    checking chromedriver versions:
    BEGIN: PREDOWNLOAD
    BEGIN: DOWNLOAD
    BEGIN: POSTDOWNLOAD
    checking geckodriver versions:
    BEGIN: PREDOWNLOAD
    BEGIN: DOWNLOAD
    BEGIN: POSTDOWNLOAD
    checking phantomjs versions:
    BEGIN: PREDOWNLOAD
    BEGIN: DOWNLOAD
    BEGIN: POSTDOWNLOAD
    [1] "Connecting to remote server"
    
    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
    Build info: version: '4.0.0-alpha-2', revision: 'f148142cf8', time: '2019-07-01T21:30:10'
    System info: host: 'L90801', ip: '10.146.202.24', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_162'
    Driver info: driver.version: unknown
    remote stacktrace: 
    
    Could not open firefox browser.
    Client error message:
         Summary: SessionNotCreatedException
         Detail: A new session could not be created.
         Further Details: run errorDetails method
    Check server log for further details.
  • Have you taken a look [here](https://stackoverflow.com/a/65322308/9494044)? – Dunois Sep 23 '21 at 21:29
  • Yes, the problem is that it's python, and I'm working with R. I've tried to play with paths in RStudio, but nothing worked. If you could elaborate how I can pass an absolute path to Firefox with RSelenium, that would be nice. – Eugene Paulia Sep 23 '21 at 22:22
  • Tried this approach, no result `exCap <- list( "moz:firefoxOptions" = list( args = list('--headless'), binary = list('--C:\\\\Program Files\\\\Mozilla Firefox\\\\firefox.exe') ) ) # and use it here rD <- rsDriver( browser = "firefox", extraCapabilities = exCap )` @Dunois – Eugene Paulia Sep 23 '21 at 22:43
  • There can be many reasons, update your firefox browser, update the java, install latest package, mention the `version` of firefox , mention the `port`. – Nad Pat Sep 24 '21 at 08:04
  • Hm, are you using `Docker` with `RSelenium` as recommended [here](https://stackoverflow.com/a/45401318)? I don't think the `rsDriver` approach works at all. – Dunois Sep 24 '21 at 08:51
  • @NadPat have done it multiple times, still the same error pops up – Eugene Paulia Sep 24 '21 at 16:14
  • @Dunois I'm working on a PC w/o admin rights, so installing and running Docker is not possible for me, thus I chose rsDriver. – Eugene Paulia Sep 24 '21 at 16:16
  • I've never been able to get `rsDriver` to work, so I'm not sure what other options you have here within `RSelenium`. – Dunois Sep 24 '21 at 20:21
  • Consider adding firefox to Path variable, refer https://stackoverflow.com/questions/24622725/how-to-set-path-on-windows-through-r-shell-command https://stackoverflow.com/questions/43882307/where-should-i-set-the-variable-path-in-r https://community.rstudio.com/t/adding-to-the-path-variable/12066 – Nad Pat Sep 25 '21 at 06:03
  • @NadPat yeah, I did that – Eugene Paulia Sep 25 '21 at 19:16

1 Answers1

0

This code works fine to me, remember, you will need to have java installed and set which one is your chromeover

in error message appears which ones is available for you

rd <- rsDriver(port = 4445L,browser = "chrome", chromever = "95.0.4638.54")
rem <- rd$client
rem$open()
matheus
  • 11
  • 4