Skip to content

Instantly share code, notes, and snippets.

@shanehh
Created September 7, 2021 06:18
Show Gist options
  • Save shanehh/6b4f7597a8b36a4d82323cc679796639 to your computer and use it in GitHub Desktop.
Save shanehh/6b4f7597a8b36a4d82323cc679796639 to your computer and use it in GitHub Desktop.
make driver as a global variable, while under with
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
D = None
def google(keyword):
D.get(f"https://www.google.com.hk/search?q={keyword}")
with webdriver.Chrome(ChromeDriverManager().install()) as driver:
D = driver
google("hello")
breakpoint()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment