Advertisement
stalin_bro

Untitled

May 12th, 2022
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.74 KB | None | 0 0
  1. import time
  2. from pathlib import Path
  3.  
  4. from selenium import webdriver
  5. from selenium.webdriver.chrome.options import Options
  6. from selenium.webdriver.common.by import By
  7. from selenium.webdriver.common.keys import Keys
  8. from selenium.webdriver.chrome.service import Service
  9. from selenium.webdriver.common.action_chains import ActionChains
  10. from selenium.webdriver.support.ui import WebDriverWait
  11. from selenium.webdriver.support import expected_conditions as Ec
  12.  
  13. # Переменная пути к файлам
  14. currentDir = Path.cwd()
  15. files_for_upload_path = currentDir / 'regions_upload' / 'file name.xlsx'
  16. print(f'{type(files_for_upload_path)} : {files_for_upload_path}')
  17. # Запуск браузера
  18. options = Options()
  19. options.binary_location = "C:/chromium-gost/chrome.exe"
  20. service = Service(executable_path='chromedriver.exe')
  21. driver = webdriver.Chrome(service=service, options=options)
  22. driver.maximize_window()
  23.  
  24. # Вход на сайт, ввод логина и пароля
  25. driver.get("site")
  26. login_field = WebDriverWait(driver, 10).until(Ec.element_to_be_clickable((By.ID, "login")))
  27. login_field.send_keys("login")  # Вводим логин
  28.  
  29. pass_field = WebDriverWait(driver, 10).until(Ec.element_to_be_clickable((By.ID, "password")))
  30. pass_field.send_keys("pass" + Keys.ENTER)
  31.  
  32. # # Переход в форму заполнения
  33. driver.get("next_url")
  34. time.sleep(10)
  35.  
  36. driver.switch_to.frame('ifm')
  37.  
  38. time.sleep(5)
  39.  
  40. 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')
  41. driver.find_element(fileInput).send_keys(files_for_upload_path)
  42.  
  43. time.sleep(5)
  44. driver.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement