Ir para conteúdo
Fórum Script Brasil

davimilazzo

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Tudo que davimilazzo postou

  1. eis o código: Sub CleanAndAutomateWithValidationAndErrorHandling() Dim bot As New WebDriver Dim Keys As New Selenium.Keys Dim rng As Range Dim cell As Range Dim valor As String Dim ws As Worksheet Set ws = ThisWorkbook.Sheets("PROCESSOS MS") ' Remove linhas vazias da coluna A ws.Columns("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete Set rng = ws.Range("A2:A" & ws.Cells(Rows.Count, "A").End(xlUp).Row) bot.Start "chrome" bot.Get "https://pje1g.trf1.jus.br/pje/login.seam" Application.Wait Now + TimeValue("0:00:20") bot.Get "https://pje1g.trf1.jus.br/pje/Processo/ConsultaProcesso/listView.seam" Application.Wait Now + TimeValue("0:00:20") For Each cell In rng ' Armazena o valor da célula atual em uma variável valor = cell.value ' Divide os dígitos da numeração Dim digito1to7 As String Dim digito8to9 As String Dim digito10to13 As String Dim digito17to20 As String digito1to7 = Left(valor, 7) digito8to9 = Mid(valor, 8, 2) digito10to13 = Mid(valor, 10, 4) digito17to20 = Mid(valor, 17, 4) ' Preenche os campos na página usando os IDs específicos bot.FindElementById("fPP:numeroProcesso:numeroSequencial").SendKeys digito1to7 bot.FindElementById("fPP:numeroProcesso:numeroDigitoVerificador").SendKeys digito8to9 bot.FindElementById("fPP:numeroProcesso:Ano").SendKeys digito10to13 bot.FindElementById("fPP:numeroProcesso:NumeroOrgaoJustica").SendKeys digito17to20 ' Pressiona Enter bot.FindElementByXPath("//*[@id=""fPP:numeroProcesso:NumeroOrgaoJustica""]").SendKeys Keys.Enter ' Aguarda 5 segundos Application.Wait Now + TimeValue("0:00:05") Next cell Set bot = Nothing End Sub Sub FillFieldWithID(bot As WebDriver, fieldID As String, value As String) Dim inputField As WebElement Set inputField = bot.FindElementByXPath("//*[@id=""" & fieldID & """]") ' Limpa o campo de texto antes de preencher inputField.Clear ' Preenche o campo com o valor inputField.SendKeys value End Sub Sub MoveToSheet(cell As Range, destSheet As Worksheet) cell.EntireRow.Copy destSheet.Rows(destSheet.Cells(Rows.Count, "A").End(xlUp).Row + 1) Application.CutCopyMode = False End Sub Function IsTRF1(value As String) As Boolean ' Verifica se o valor é do TRF1 (14º dígito é 4, 15º é 0 e 16º é 1) If Len(value) = 20 And Mid(value, 14, 1) = "4" And Mid(value, 15, 1) = "0" And Mid(value, 16, 1) = "1" Then IsTRF1 = True Else IsTRF1 = False End If End Function
×
×
  • Criar Novo...