2

So I have written a script in python that used selenium to automate some websites. I want this script to be able to be run on a windows computer as an exe maybe?

My question is, how do I approach this? My script has a dependency on geckodriver.exe

How do I embed that into the final executable file?

1 Answers1

0

There is an automated way to get gecko driver binary download etc with webdrivermanager api. This package downloads binaries/executables in an automated way and helps us to avoid all the manual steps that we do previously related to drivers to run our tests.

How do we use this in our project?

Only setup required is to install this package using ‘pip’.

pip install webdriver_manager

For Firefox

from webdriver_manager.firefox import GeckoDriverManager
from selenium import webdriver

driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
driver.get("http://www.google.com/")
print driver.title
driver.quit()

You can check more details here about set up and use. Pypi docs for webdrivermanager

Muzzamil
  • 2,823
  • 2
  • 11
  • 23