Skip to content

Instantly share code, notes, and snippets.

@dev4Fun
Created September 10, 2020 03:21
Show Gist options
  • Select an option

  • Save dev4Fun/ee37ad5a38deaac95f00d603919360e1 to your computer and use it in GitHub Desktop.

Select an option

Save dev4Fun/ee37ad5a38deaac95f00d603919360e1 to your computer and use it in GitHub Desktop.
import pathlib
from selenium import webdriver
import config
def configure_chrome_driver():
options = webdriver.ChromeOptions()
options.add_argument(f"user-data-dir={pathlib.Path(__file__).parent.absolute().joinpath('chrome-profile')}")
# disable image loading for better performance
# options.add_experimental_option("prefs", {"profile.managed_default_content_settings.images": 2})
the_driver = webdriver.Chrome(executable_path=config.DRIVER_EXECUTABLE_PATH, options=options)
# page loading time and wait time for page reload
the_driver.set_page_load_timeout(5)
the_driver.implicitly_wait(2)
return the_driver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment