-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_driver.py
73 lines (58 loc) · 2.66 KB
/
get_driver.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import undetected_chromedriver as uc
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver import Keys, ActionChains
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import pretty_errors
import os
import requests
import re
import subprocess
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
extension = 'omghfjlpggmjjaagoclmmobgdodcjboh'
def new_drb():
chromeOptions = uc.ChromeOptions()
caps = DesiredCapabilities().CHROME
caps["pageLoadStrategy"] = "eager"
chromeOptions.headless = False
driver = uc.Chrome(options=chromeOptions, desired_capabilities=caps)
return driver
def new_brave_dr():
brave_path = "C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"
chromedriver_path = r"C:\Users\user\PycharmProjects\InnokentiyHomeWorker\chromedriver.exe"
chrome_options = uc.ChromeOptions()
chrome_options.binary_location = brave_path
chrome_options.add_argument("--single-process")
chrome_options.headless = False
caps = DesiredCapabilities().CHROME
caps["pageLoadStrategy"] = "eager"
service = Service(chromedriver_path)
driver = uc.Chrome(service=service, options=chrome_options, desired_capabilities=caps)
return driver
def check_for_chrome_update():
driver = new_drb()
driver.get("chrome://version/")
status_element = driver.find_element(
By.XPATH,
'/html/body/div[1]/table/tbody/tr[1]/td[2]/span'
)
# Проверяем статус обновления
update_text = status_element.text
print(f"Статус обновления: {update_text}")
if "Доступно обновление" in update_text:
print("Обновление доступно. Запуск загрузки...")
# Нажимаем кнопку обновления
update_button = driver.find_element(By.XPATH, "//button[contains(text(), 'Перезагрузить')]")
update_button.click()
print("Обновление установлено. Требуется перезагрузка браузера.")
else:
print("Установлена последняя версия Chrome.")