Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- from pathlib import Path
- from selenium import webdriver
- from selenium.webdriver.chrome.options import Options
- from selenium.webdriver.common.by import By
- from selenium.webdriver.common.keys import Keys
- from selenium.webdriver.chrome.service import Service
- from selenium.webdriver.common.action_chains import ActionChains
- from selenium.webdriver.support.ui import WebDriverWait
- from selenium.webdriver.support import expected_conditions as Ec
- # Переменная пути к файлам
- currentDir = Path.cwd()
- files_for_upload_path = currentDir / 'regions_upload' / 'file name.xlsx'
- print(f'{type(files_for_upload_path)} : {files_for_upload_path}')
- # Запуск браузера
- options = Options()
- options.binary_location = "C:/chromium-gost/chrome.exe"
- service = Service(executable_path='chromedriver.exe')
- driver = webdriver.Chrome(service=service, options=options)
- driver.maximize_window()
- # Вход на сайт, ввод логина и пароля
- driver.get("site")
- login_field = WebDriverWait(driver, 10).until(Ec.element_to_be_clickable((By.ID, "login")))
- login_field.send_keys("login") # Вводим логин
- pass_field = WebDriverWait(driver, 10).until(Ec.element_to_be_clickable((By.ID, "password")))
- pass_field.send_keys("pass" + Keys.ENTER)
- # # Переход в форму заполнения
- driver.get("next_url")
- time.sleep(10)
- driver.switch_to.frame('ifm')
- time.sleep(5)
- fileInput = driver.find_element(By.CSS_SELECTOR, '#x-auto-3 > div.w-b-com-sencha-gxt-theme-triton-client-base-panel-Css3HeaderAppearance-Css3HeaderStyle-headerBar > table > tbody > tr > td:nth-child(2) > div > input')
- driver.find_element(fileInput).send_keys(files_for_upload_path)
- time.sleep(5)
- driver.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement