Created
September 7, 2021 06:18
-
-
Save shanehh/6b4f7597a8b36a4d82323cc679796639 to your computer and use it in GitHub Desktop.
make driver as a global variable, while under with
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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