VB Net HtmlAgility can't pass next xpath / empty blank result - vb.net

I can't pass the next xpath using htmlagility vbnet, innertext blank. and please explain. this is bug?
https://dotnetfiddle.net/swXn7f

Related

How to retrieve the text of a hidden element using selenium

Here we know the Birimingam value. Based out of that value need to retrieve the text "BHM". Have indicated this in the image. How to retrieve hidden text which is "BHM" using Birimingham value xpath?
Try this xpath to access the element
//span[text()='Birmingham']/../../preceding-sibling::span/span

Selenium Webscraping - Print element that is not visible on the site but its on Inspect

enter image description here
I'm trying to print this 91040 from the site but I can't seem to do it and I think the reason is that 91040 is not visible on the site but only on inspect.
element = driver.find_element(By.XPATH,'//div[#class="code-container"]//span[2]')
When I paste this XPATH in the find bar on Inspect it locates the item but when I'm trying to print the element nothing gets printed. I tried these options.
print(element)
print(element.text)
So I'm thinking that the problem is that 91040 is not an actual visible text.
For anyone having the same problem I found the answer
hidden_text = element.get_attribute("textContent")

VBA selenium to click on a nearby grid column

A problem derived from my previous question:" VBA to find if an element contains certain texts"
I find the desired text using :
driver.FindElementByXPath("//*[#class='x-grid3-cell-inner' and text()='TEXT']")
but it is unclickable. The box in the next column is where i want to click.
How to click a nearby grid column ?
Ca72-4 is what i try to find.
The grid row of Ca72-4 may differ.
Path of the text (in selenium) :
xpath=//div[42]/table/tbody/tr/td[3]/div
The yellow box on the right is input.
Path of the desired target (in selenium) :
xpath=//div[42]/table/tbody/tr/td[4]/div
Thank you for your help.
To click() in the adjascent cell next to the text Ca72-4 you can use the following xpath based Locator Strategy:
driver.FindElementByXPath("//div[#class='x-grid3-cell-inner' and text()='Ca72-4']//following::td[1]/div").Click
A solution may be to dim an integer and to loop and check all div[#] and then use the integer with targets xpath. But i'd really like to avoid loops if possible.

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?
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")
Sometimes I have found that I have to execute javascript to get what I'm after. You can try
name=driver.ExecuteScript("document.getElementsByClassName('ng-binding')[91].innerText;")

Getting info from web page between <strong> TAGS

So i am trying to get some text from a web page that is located between tags. I have included an image that shows the text i am trying to get.
highlighted text
the code i have currently is as follows although it is gathering other information as well which is not needed.
For Each ele As HtmlElement In WebBrowser1.Document.All
If ele.GetAttribute("className").ToLower.Contains("cwybtn") Then
Dim colourSource As String = ele.GetAttribute("innerText")
'ListBox2.Items.Add(colourSource) 'Adds all .jpg images to the ListBox
MsgBox(colourSource)
End If
Next
Has anyone got any ideas
why don't you try with tagName? you have an element from class name try to get the element from that element as tagName
hope this will help getElementsByTagName("strong")
Ankit
thanks for that! I for got about tagname to be honest, i have now fixed it!
For Each strongTag As HtmlElement In WebBrowser1.Document.GetElementsByTagName("strong")
MsgBox(strongTag.InnerText)
Next