Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make exe file from python selenium tests

I try to build my python selenium tests in exe file and run it on many machines for keeping tests independent of the environment. But result *.exe file can't find selenium webdriver. How can I include all selenium dependencies in *.exe file? Or maybe is there some another way for it? Is it possible to make virtual environment and distribute it?

like image 661
Eugene Avatar asked Nov 11 '22 14:11

Eugene


1 Answers

I am assuming you are using py2exe for generating exe. You will need to specify the location of selenium webdriver in the setup.py file.

Following code should help:

from distutils.core import setup
import py2exe

# Change the path in the following line for webdriver.xpi
data_files = [('selenium/webdriver/firefox', ['D:/Python27/Lib/site-packages/selenium/webdriver/firefox/webdriver.xpi'])]

setup(
    name='General name of app',
    version='1.0',
    description='General description of app',
    author='author name',
    author_email='author email',
    url='',
    windows=[{'script': 'abc.py'}],   # the main py file
    data_files=data_files,
    options={
        'py2exe':
            {
                'skip_archive': True,
                'optimize': 2,
            }
    }
)
like image 128
Vikas Ojha Avatar answered Nov 15 '22 06:11

Vikas Ojha