Search code examples
vbaseleniuminnertext

VBA automation can't get innerText (innerHTML, value)


So, i've gotten innertext many times. This time, it's simply not working. Tried many alternatives.

First of All I'm using Selenium on VBA to use chromedriver. The source website is "[http://www.fazenda.df.gov.br/area.cfm?id_area=1536]" This website operates on a Iframe. After half an hour trying to get the inner text from it, i figured that the link in its code works just as fine: "[http://publica.agnet.fazenda.df.gov.br/FichaImovel/#/FichaCadastral]". This last one seems to operate on someting call "Angular".

The menu with the innertext i required is a dropdown one. As a dummy value, you can use 50868748. The dropdown text that it generates is composed by 15 lines and one table. The info that i need is on the 15th line, "Nome do Responsável", or in the column 2 line 2 on the table.

I managed to place the code and generate the dropdown list, but i can't manage to get the inner text.

Here is my code:

Dim iptu As String

Dim driver As New ChromeDriver

With driver


.Start 
iptu = 50868748 'dummy
.Get "http://publica.agnet.fazenda.df.gov.br/FichaImovel/#/FichaCadastral"

.FindElementById("inscricaoImovel").Clear
.FindElementById("inscricaoImovel").SendKeys iptu
.FindElementsById("btnCadastro")(2).Click

.Wait (300)

'until here, everything works fine

Dim label As Object
Dim name As String


Set label = .FindElementsByClass("ng-binding")(91)
'as you can see, i end up using this class(91) to get the value on the table, but i can get from the 15th line too


name = label.getAttribute("innerText") 'Error is here

'i've tried .innerText, .innerHTML and others. The error is always "object does not accept property or method" Error 438.

end with

The chrome driver is up to date. Also, the page source does not cointain the info i need.

Anyone can help me out?


Solution

  • To get InnerText of the element, You need to call Text method

    Set label = .FindElementsByClass("ng-binding")(91)
    
    name = label.Text
    

    To get inner Html,

    name = label.Attribute("innerHTML")