@@ -400,9 +400,9 @@ class SigaDespesasAutomation:
" AppleWebKit/537.36 (KHTML, like Gecko) "
" AppleWebKit/537.36 (KHTML, like Gecko) "
" Chrome/124.0.0.0 Safari/537.36 "
" Chrome/124.0.0.0 Safari/537.36 "
) ,
) ,
args = [ " --disable-blink-features=AutomationControlled " ] ,
args = [ " --disable-blink-features=AutomationControlled " , " --start-maximized " ],
ignore_default_args = [ " --enable-automation " ] ,
ignore_default_args = [ " --enable-automation " ] ,
viewport= { " width " : 1366 , " height " : 768 } ,
# viewport={"width": 1366, "height": 768} ,
locale = " pt-BR " ,
locale = " pt-BR " ,
timezone_id = " America/Cuiaba " ,
timezone_id = " America/Cuiaba " ,
)
)
@@ -729,6 +729,12 @@ class SigaDespesasAutomation:
press_enter_for_ajax = True ,
press_enter_for_ajax = True ,
)
)
# Faça com que seja apertado a tecla ESC
await page . keyboard . press ( " Escape " , delay = 400 )
await human_delay ( 300 , 600 )
await page . keyboard . press ( " Escape " , delay = 500 )
await human_delay ( 300 , 600 )
# 7. Validação do Histórico (Rateio)
# 7. Validação do Histórico (Rateio)
logger . info ( f " 7️ ⃣ Validando Histórico... " )
logger . info ( f " 7️ ⃣ Validando Histórico... " )
historico_select = page . locator ( " #f_historico_debito " ) . first
historico_select = page . locator ( " #f_historico_debito " ) . first
@@ -738,6 +744,12 @@ class SigaDespesasAutomation:
if " 12 - DESP.BANC " in hist_text :
if " 12 - DESP.BANC " in hist_text :
logger . info ( f " 7️ ⃣ Histórico de Rateio Validado: ' { hist_text . strip ( ) } ' " )
logger . info ( f " 7️ ⃣ Histórico de Rateio Validado: ' { hist_text . strip ( ) } ' " )
# Faça com que seja apertado a tecla ESC
await page . keyboard . press ( " Escape " , delay = 400 )
await human_delay ( 300 , 600 )
await page . keyboard . press ( " Escape " , delay = 500 )
await human_delay ( 300 , 600 )
# 8. Complemento (Rateio)
# 8. Complemento (Rateio)
logger . info ( f " 8️ ⃣ Preenchendo Complemento (Rateio): ' { expense . complemento } ' ... " )
logger . info ( f " 8️ ⃣ Preenchendo Complemento (Rateio): ' { expense . complemento } ' ... " )
complemento_input = page . locator ( " #f_complemento2 " ) . first
complemento_input = page . locator ( " #f_complemento2 " ) . first
@@ -808,7 +820,7 @@ class SigaDespesasAutomation:
logger . info ( " ℹ ️ Modal ' Sim ' não foi solicitada ou fechou automaticamente. " )
logger . info ( " ℹ ️ Modal ' Sim ' não foi solicitada ou fechou automaticamente. " )
# 2. Confirmação de mensagem de sucesso ("OK")
# 2. Confirmação de mensagem de sucesso ("OK")
ok_btn = page . locator ( " button:has-text( ' OK ' ), button.btn-primary:has-text( ' OK ' ), button[data-bb-handler= ' ok ' ], .modal-footer button:has-text( ' OK ' ) " ) . first
ok_btn = page . locator ( " button:has-text( ' Ok ' ), button.btn-primary:has-text( ' Ok ' ), button[data-bb-handler= ' bota o' ], .modal-footer button:has-text( ' Ok ' ) " ) . first
try :
try :
await ok_btn . wait_for ( state = " visible " , timeout = 6000 )
await ok_btn . wait_for ( state = " visible " , timeout = 6000 )
logger . info ( " ℹ ️ Modal de sucesso detectada. Clicando em ' OK ' ... " )
logger . info ( " ℹ ️ Modal de sucesso detectada. Clicando em ' OK ' ... " )