RWB
RWB

Reputation: 55

VBA Selenium: How to Extract <!-- p> non-displayed comment text, from a Web Page Element

from web page HTML

I am doing a county property survey. The mailing address is included on each record/webpage as a non-displayed comment <!-- p> with a p tag I am trying to extract those non non-displayed comments which contain the mailing and physical address of the property (see attached jpeg)

I have tried various forms of comment and attribute schemes to add on to the CSS and xPath Selectors for the h2 header above the comments - but no go so far

Set Mailing = MyBrowser.FindElementsByCss("#lxT413 > table > tbody > tr:nth-child(2) > td > h2) Set Mailing = MyBrowser.FindElementByXPath("//*[@id="lxT413"]/table/tbody/tr[2]/td/h2")

Upvotes: 0

Views: 525

Answers (2)

RWB
RWB

Reputation: 55

I got it!!!

Set Mailing = MyBrowser.FindElementByCss("#lxT413 > table > tbody > tr:nth-child(2) > td")

Debug.Print Mailing.Attribute("outerHTML")

Upvotes: 1

Shatas
Shatas

Reputation: 171

Have a look here. Also looking at the screenshot you've provided, it seems that the commented portion of the DOM is not inside the h2 element but rather inside the td element, maybe that is the reason why you can't reach it?

Upvotes: 1

Related Questions