VBA 自动化无法获取 innerText (innerHTML, value)
VBA automation can't get innerText (innerHTML, value)
所以,我得到了很多次内文。这一次,它根本不起作用。尝试了很多选择。
首先
我在 VBA 上使用 Selenium 来使用 chrome 驱动程序。
源网站是“[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]”。最后一个似乎是在某个调用 "Angular".
上运行
我需要的带有内文的菜单是下拉菜单。作为虚拟值,您可以使用 50868748。它生成的下拉文本由 15 行和一个 table 组成。我需要的信息在第 15 行 "Nome do Responsável" 或 table.
的第 2 行第 2 列中
我设法放置了代码并生成了下拉列表,但我无法获取内部文本。
这是我的代码:
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)
'到这里,一切正常
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
'我试过 .innerText、.innerHTML 和其他。错误始终是 "object does not accept property or method" 错误 438。
end with
chrome 驱动程序是最新的。另外,页面源不包含我需要的信息。
谁能帮帮我?
要获取元素的InnerText,需要调用Text方法
Set label = .FindElementsByClass("ng-binding")(91)
name = label.Text
获取内在Html,
name = label.Attribute("innerHTML")
有时我发现我必须执行 javascript 才能得到我想要的东西。你可以试试
name=driver.ExecuteScript("document.getElementsByClassName('ng-binding')[91].innerText;")
所以,我得到了很多次内文。这一次,它根本不起作用。尝试了很多选择。
首先 我在 VBA 上使用 Selenium 来使用 chrome 驱动程序。 源网站是“[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]”。最后一个似乎是在某个调用 "Angular".
上运行我需要的带有内文的菜单是下拉菜单。作为虚拟值,您可以使用 50868748。它生成的下拉文本由 15 行和一个 table 组成。我需要的信息在第 15 行 "Nome do Responsável" 或 table.
的第 2 行第 2 列中我设法放置了代码并生成了下拉列表,但我无法获取内部文本。
这是我的代码:
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)
'到这里,一切正常
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
'我试过 .innerText、.innerHTML 和其他。错误始终是 "object does not accept property or method" 错误 438。
end with
chrome 驱动程序是最新的。另外,页面源不包含我需要的信息。
谁能帮帮我?
要获取元素的InnerText,需要调用Text方法
Set label = .FindElementsByClass("ng-binding")(91)
name = label.Text
获取内在Html,
name = label.Attribute("innerHTML")
有时我发现我必须执行 javascript 才能得到我想要的东西。你可以试试
name=driver.ExecuteScript("document.getElementsByClassName('ng-binding')[91].innerText;")