Setting path to firefox binary on windows with selenium webdriver

0
0

I am trying to build a utility function to output beautiful soup code to a browser I have the following code:

def bs4_to_browser(data):
from selenium import webdriver
driver
= webdriver.Firefox(path="F:\FirefoxPortable\Firefox.exe")
driver
.get("about:blank")
data
= '<h1>test</h1>' # supposed to come from BeautifulSoup
driver
.execute_script('document.body.innerHTML = "{html}";'.format(html=data))
return

when I run this I get:

TypeError at /providers/
__init__
() got an unexpected keyword argument 'path'

I am using win7. How to I set the path to the portable firefox executable?

  • You must to post comments
0
0

To set the custom path to Firefox you need to use FirefoxBinary:

from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary
= FirefoxBinary('F:\FirefoxPortable\Firefox.exe')
driver
= webdriver.Firefox(firefox_binary=binary)

Or, alternatively, add F:\FirefoxPortable to the PATH environment variable and fire up Firefox in a usual way:

driver = webdriver.Firefox()
  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website