0

セレンとwebdriver(Chromedriver)を使用するpythonスクリプトを作成しました。このスクリプトを完了した後、私はcx_freezeを使って自分のスクリプトをスタンドアロンのexeファイルにコンパイルしました。ダブルクリックでスクリプトを実行できます。しかし、セレンを使って、自分のPCにインストールしたクロムアプリケーションに沿ってダウンロードしたchromedriverファイルを使用しています。クロムをインストールせずにセレンベースのスタンドアロンexeを起動

私のやりたいこと、またはしようとすると、私のexeファイルはchromedriverで動作し、ユーザーは自分のコンピュータにGoogle Chromeをインストールする必要はありません。とにかく、私はクロームを同じディレクトリにパッケージとして含めて、これを回避することができますか?

私は他のアイデアにもオープンしています。

答えて

0

いつでもオフラインインストーラをバンドルしてインストールするように指示し、実行ファイルを実行してインストールするだけでインストールできます。 (利用可能なhere

注:調べなければならないかもしれないいくつかのライセンス問題があるかもしれません。

それ以外の場合は、webbrowser.open('https://www.google.com/chrome/browser/')を使用してchromeのインストールページに誘導してください。次のようなもの:

try: 
    selenium.webbrowser('chrome') # Or whatever the command is 
except 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) 
    if input('Open ' + INSTALL_PAGE + '? [yes/no]').lower().startswith('y'): 
     webbrowser.open(INSTALL_PAGE) # Uses default browser 

    # If you are running the offline installer 

    import 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')) 
関連する問題