Search code examples
pythonfirefoxseleniumpy2app

py2app selenium without firefox install


I am wondering if there is a way within py2app to include the Firefox browser, or if there is a way for Selenium to use Firefox without having to install Firefox on the host machine.

I have created an app with py2app that uses Selenium, however, I have Firefox installed on my machine, but not everyone that will receive the app will have Firefox installed. I am looking for a way to either include Firefox in the distribution or go around this.


Solution

  • Script will not run if Firefox is not preinstalled. You can test your script with other browser, for example Chrome. If it works on Chrome also, then you can edit script like this:

    from selenium.common.exceptions import WebDriverException
    try:
        driver = webdriver.Firefox()
    except WebDriverException:
        driver = webdriver.Chrome()
    

    You can add same for few more browsers (IE, Opera, Safari...) to be sure that script will run on users machine