-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnection_google.py
30 lines (22 loc) · 1007 Bytes
/
connection_google.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import subprocess
import importlib.util
def start_driver():
# Verify if the package is installed
package_name = "webdriver_manager"
if importlib.util.find_spec(package_name) is None:
print(f"Package {package_name} not found. Installing...")
subprocess.run(["pip", "install", "--upgrade", package_name], check=True)
else:
print(f"Package {package_name} is already installed.")
from webdriver_manager.chrome import ChromeDriverManager
# Configurations to start the browser
options = webdriver.ChromeOptions()
service = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=service, options=options)
return driver