Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom path to firefox.exe? #156

Closed
luke-a opened this issue Nov 22, 2017 · 2 comments
Closed

Custom path to firefox.exe? #156

luke-a opened this issue Nov 22, 2017 · 2 comments

Comments

@luke-a
Copy link

@luke-a luke-a commented Nov 22, 2017

How can I specify a custom path to firefox.exe and to geckodriver.exe using RSelenium? For example in Python, this works well:

from selenium import webdriver
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary(r'C:\FirefoxPortable\App\Firefox64\firefox.exe')
executable = r'C:\...\geckodriver.exe'
firefoxProfile = FirefoxProfile()
browser = webdriver.Firefox(firefox_binary=binary, firefox_profile=firefoxProfile, executable_path=executable)

I believe one could specify both using the javaargs argument form startServer. However, I got no idea how to specify any of the paths in RSelenium::rsDriver or wdman::selenium. Thanks for any hints in advance.

@johndharrison
Copy link
Member

@johndharrison johndharrison commented Nov 22, 2017

@luke-a you can pass additional arguments to the JVM or to selenium via wdman for example:

commandOutput <- wdman::selenium(retcommand = TRUE, 
                jvmargs = list('--somejvmarg=somejvmvalue'), 
                selargs = list('--someselarg=someselvalue'))
# check what will be passed when running process
> commandOutput


> commandOutput 
[1] "C:\\PROGRA~3\\Oracle\\Java\\javapath\\java.exe --somejvmarg=somejvmvalue -Dwebdriver.chrome.driver=\"C:\\Users\\john\\AppData\\Local\\binman\\binman_chromedriver\\win32\\2.33/chromedriver.exe\" -Dwebdriver.gecko.driver=\"C:\\Users\\john\\AppData\\Local\\binman\\binman_geckodriver\\win64\\0.19.1/geckodriver.exe\" -Dphantomjs.binary.path=\"C:\\Users\\john\\AppData\\Local\\binman\\binman_phantomjs\\windows\\2.1.1/phantomjs-2.1.1-windows/bin/phantomjs.exe\" -jar \"C:\\Users\\john\\AppData\\Local\\binman\\binman_seleniumserver\\generic\\3.7.1/selenium-server-standalone-3.7.1.jar\" --someselarg=someselvalue -port 4567"

reading https://github.com/mozilla/geckodriver#firefox-capabilities it should however be possible to
set the location of the custom binary as an extra capability. Something akin to

rsDriver(browser = "firefox", 
         extraCapabilities = list(
           `moz:firefoxOptions` = list(
             binary = `/usr/bin/firefox`
           )
         ))

should work.

@luke-a
Copy link
Author

@luke-a luke-a commented Nov 22, 2017

That's great, thanks so much - it worked:

# binman::list_versions("geckodriver")
selServ <- wdman::selenium(retcommand = FALSE, port = 4444L, check = FALSE, geckover = "0.19.0")
# selServ$log()
remDr <- remoteDriver(browserName = "firefox", port = 4444L, extraCapabilities = list(
  `moz:firefoxOptions` = list(
    binary = "W:/FirefoxPortable/App/Firefox64/firefox.exe" # FF v56.0.2 x64
  )
))
remDr$open()

@luke-a luke-a closed this as completed Nov 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants