Reputation: 323
Basically I want to learn how to add my chromedriver into my github repo so that people can run my python script on their app.
I've downloaded the chromedriver for linux and executed it via local path.
I've seen that people are adding chromedriver_installer into their requirements.txt, but users would have to manually change the script to add the path to where chromedriver is installed. Is there a way to do this automatically?
So what is the best way to add it to my project and still make it able to work on every machine?
Upvotes: 2
Views: 1579
Reputation: 3711
I like to use the chromedriver-autoinstaller. It's very simple, just install with pip and you can use it in your code like this, without needing chromedriver actually installed/pushed to your repo.
from selenium import webdriver
import chromedriver_autoinstaller
chromedriver_autoinstaller.install()
#Chrome options
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument("--disable-infobars")
chrome_options.add_argument('--disable-dev-shm-usage')
#Run chrome
driver = webdriver.Chrome(options=chrome_options)
# do the code for your test
Upvotes: 3