| || |
How to search through entire HTML source?
There are certain situations where I would need to search for information from within the HTML source. The manual method would be to right-click, and select "View Source". (Alternatively, file, save as...)
Is there any easy method in Robot to handle this? I've used Inspector, hoping to use the SQAGetPropertyAsString function, however I cannot access the entire HTML sometimes.
My only solution I can think of is to do a file\save, and then execute a command-line search program (with InStr()-like capabilities), and work with the return code. (or, use Notepad search)
Re: How to search through entire HTML source?
I remember trying something like this a while ago. I used SQAGetProperty to capture the innerText property of the htmlpage, which contained all the information I needed for my test (though not all of the information I'd've seen via View Source, I don't think.)
there were other properties available (e.g. outerText) that contained data from the htmlpage too. I think I chose the property I did because I was looking for a section between certain tags that were included in one property but not the other.
This worked on webpages on one browser-fronted app I tried it on, but not in another. The unsuccessful attempt was against an app with much 'heavier' html pages - the first app displayed very simple pages, but saving the source text of a page in the second app gave filesizes up to 80K. I wondered if the reason it didn't work was because of the limit on the length of a string in Robot, and struggled with it a bit.
In the end I got it to do a R-click/Save As to a known location, wrote a Robot function to parse lines in the file and chop out the bits I didn't need, leaving the bit I was actually interested in -which by then was short enough to fit into a Robot string so I could use standard string manipulation functions on it.
This seemed really clunky (but did get me what I needed!) - I wouldn't be at all surprised to hear there's a much neater way of doing it though. One idea I had was to do *all* the manipulation of the Saved As text file in perl, which is obviously much more powerful with regular expressions and stuff.
hope this is of some help anyway