Página 1 de 1

Coletar informações do chrome

Enviado: Ter Fev 19, 2019 3:22 pm
por saulofelipe
estou tentando coletar as informações que gero em um site de consulta de clientes. eu consegui fazer todos os passos do video do Thomas e consigo gerar a informação e coloca-la em uma msgbox.
https://www.youtube.com/watch?v=IoTMNw- ... O7&index=1
No entanto eu preciso transferir essa informação para a minha planilha, por exemplo ThisWorkbook.Sheets("Plan1").range ("A10").

segue o meu código:

Dim driver As WebDriver

Public Sub teste()
Set driver = New ChromeDriver
driver.Get "endereço do site"

SendKeys "usuário"

driver.FindElementById("txtSenha").ClickDouble

driver.Wait 1000

SendKeys "senha"

driver.FindElementById("chkMostrarSenha").ClickDouble

driver.Wait 1000

driver.FindElementById("Entrar").click

'ATRAVEZ DA MATRICULA DO CLIENTE EU REALIZO A PESQUISA.

driver.FindElementById("body_matriculaTextBox").click

driver.Wait 1000

SendKeys (matricula do cliente)

driver.Wait 500

driver.FindElementById("body_pesquisarButton").click

'O SISTEMA ME RETORNA UMA TELA COM VARIAS INFORMAÇÕES DO CLIENTE, MAS NÃO É UMA TABELA.

Dim valorcpf As String
Dim tabelacpf As WebElement

valorcpf = driver.FindElementById("body_cpf_nascimentoTextBox").Value

MsgBox valorcpf

'ATÉ AQUI TUDO OK, CONSIGO REALIZAR TUDO, MOSTRA O CPF DO CLIENTE EM UMA MSGBOX, ASSIM COMO NO VIDEO DO THOMAS

'O CÓDIGO ABAIXO É ONDE EU NÃO CONSIGO COLOCAR O CPF MOSTRADO NA MSGBOX EM UMA DETERMINADA CELULA NA MINHA PLANILHA.

Set tabelacpf = driver.FindElementByXPath("//*[@id=""body_cpf_nascimentoTextBox""]").value

ThisWorkbook.Sheets("Plan1").range("A10") = tabelacpf

Re: Coletar informações do chrome

Enviado: Sex Fev 22, 2019 12:24 pm
por webmaster
Saulo,

Acho que esse "Set" não deveria existir.

Isso:

Código: Selecionar todos

Set tabelacpf = driver.FindElementByXPath("//*[@id=""body_cpf_nascimentoTextBox""]").value
Deveria ser isto

Código: Selecionar todos

tabelacpf = driver.FindElementByXPath("//*[@id=""body_cpf_nascimentoTextBox""]").value