88 lines
3.2 KiB
Python
88 lines
3.2 KiB
Python
# main.py
|
|
from selenium import webdriver
|
|
from selenium.webdriver.common.by import By
|
|
from selenium.webdriver.common.keys import Keys
|
|
from selenium.webdriver.support.ui import WebDriverWait
|
|
from selenium.webdriver.support import expected_conditions as EC
|
|
from selenium_stealth import stealth
|
|
import os
|
|
import time
|
|
|
|
# Set download directory path
|
|
download_dir = r"C:\Users\roberto.alves\Downloads\selenium_download"
|
|
os.makedirs(download_dir, exist_ok=True)
|
|
|
|
# Chrome options
|
|
options = webdriver.ChromeOptions()
|
|
options.add_experimental_option("prefs", {
|
|
"download.default_directory": download_dir,
|
|
"download.prompt_for_download": False,
|
|
"directory_upgrade": True
|
|
})
|
|
options.add_argument("--start-maximized")
|
|
options.add_argument("--disable-blink-features=AutomationControlled")
|
|
options.add_argument("--disable-infobars")
|
|
options.add_argument("--disable-notifications")
|
|
options.add_argument("--disable-extensions")
|
|
options.add_argument("--profile-directory=Default")
|
|
options.add_argument("--disable-popup-blocking")
|
|
options.add_argument("--disable-dev-shm-usage")
|
|
options.add_argument("--no-sandbox")
|
|
options.add_argument("--disable-features=IsolateOrigins,site-per-process")
|
|
options.add_argument("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36")
|
|
options.add_argument('--enable-unsafe-swiftshader')
|
|
|
|
# Create WebDriver instance
|
|
driver = webdriver.Chrome(options=options)
|
|
|
|
# Apply stealth settings
|
|
stealth(driver,
|
|
languages=["en-US", "en"],
|
|
vendor="Google Inc.",
|
|
platform="Win32",
|
|
webgl_vendor="Intel Inc.",
|
|
renderer="Intel Iris OpenGL",
|
|
fix_hairline=True,
|
|
)
|
|
|
|
# Navigate and login
|
|
driver.maximize_window()
|
|
driver.get('https://extranet.grupoboticario.com.br/mfe/mar/estoque/pre-consulta')
|
|
wait = WebDriverWait(driver, 90)
|
|
|
|
usuario = wait.until(EC.presence_of_element_located((By.XPATH, '/html/body/div[2]/div/div/div[2]/div/div/div[1]/form/div[3]/div[1]/input')))
|
|
usuario.send_keys('andressa.santos4')
|
|
print('usuario ok!')
|
|
|
|
senha = wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="password"]')))
|
|
senha.send_keys('Admufal@202')
|
|
|
|
entrar = wait.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="next"]')))
|
|
entrar.click()
|
|
print('entrou!!')
|
|
|
|
pdvs_select = wait.until(EC.element_to_be_clickable((By.XPATH, '/html/body/div[1]/div/div[2]/div[2]/div/div/div/div/div/div/div[2]/div[1]/div/button/span')))
|
|
pdvs_select.click()
|
|
print('pdvs clicado')
|
|
time.sleep(20)
|
|
|
|
lojas = wait.until(EC.element_to_be_clickable((By.XPATH, '/html/body/div[1]/div/div[2]/div[2]/div/div/div/div/div/div/div[2]/div[1]/div/div/div[1]/div[2]/ul/li[1]/button/span[1]/div/label/span/svg')))
|
|
lojas.click()
|
|
|
|
'''try:
|
|
accordion_btn = wait.until(EC.element_to_be_clickable((By.XPATH, "/html/body/div[1]/div/div[2]/div[2]/div/div/div/div/div/div/div[1]/div/div[2]/div[1]/ul/li[1]/button")))
|
|
accordion_btn.click()
|
|
print('clicou no accordeon')
|
|
time.sleep(20)
|
|
|
|
|
|
consultar_estoque = wait.until(EC.element_to_be_clickable((By.XPATH, "/html/body/div[1]/div/div[2]/div[2]/div/div/div/div/div/div/div[1]/div/div[2]/div[1]/ul/li[1]/div/a/div/ul/li")))
|
|
consultar_estoque.click()
|
|
print('clicou no consultar')
|
|
except:
|
|
print('nao funcionou chat :(')'''
|
|
|
|
|
|
time.sleep(50)
|
|
|