0 votes
1 view
in DevOps and Agile by (19.8k points)

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


    data = '<h1>test</h1>'  # supposed to come from BeautifulSoup

    driver.execute_script('document.body.innerHTML = "{html}";'.format(html=data))


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?



1 Answer

0 votes
by (63.4k points)

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 else, add F:\FirefoxPortable to the path environment variable and fire up Firefox in a traditional way:

driver = webdriver.Firefox()

Welcome to Intellipaat Community. Get your technical queries answered by top developers !