Skip to content Skip to sidebar Skip to footer

Launching Selenium Based Stand Alone Exe Without Chrome Installed

I have created a python script that uses selenium and a webdriver (Chromedriver). After completing this script, I used cx_freeze to compile my script into a stand alone exe file th

Solution 1:

You can always bundle the offline installer and prompt it to be installed and just run the executable to install it. (Available here)

NOTE: There may be some licensing issues which you may have to look into.

Otherwise, use webbrowser.open('https://www.google.com/chrome/browser/') to direct them to the installation page for chrome. Something like:

try:
    selenium.webbrowser('chrome')  # Or whatever the command isexcept NameOfExceptionWhenNoBrowserHere:
    # If you are opening the web page:import webbrowser

    INSTALL_PAGE = 'https://www.google.com/chrome/browser/'print('You need to have Google chrome installed.')
    print(INSTALL_PAGE)
    ifinput('Open ' + INSTALL_PAGE + '? [yes/no]').lower().startswith('y'):
        webbrowser.open(INSTALL_PAGE)  # Uses default browser# If you are running the offline installerimport subprocess
    import os

    _file_dir = os.path.dirname(os.path.realpath(__file__))

    print('You need to have Google chrome installed.')
    print('Will now open installer')

    # _file_dir is the directory of the python file.# If the installer is in the same directory, run it like this.
    subprocess.call(os.path.join(_file_dir, 'install_chrome.exe'))

Post a Comment for "Launching Selenium Based Stand Alone Exe Without Chrome Installed"