Check if a text in a webpage has hyperlink


#1

I have a use case where i have to take a screenshot of a webpage* which displays results of a search criteria. Some result ID may have hyperlink to another page (say additional details of that result) and some doesn’t. I’m looking to find a way where I could check if the result ID contains a hyperlink, and if it does, i click that and get a screenshot of the additional details as well.

*The webpage is not a public domain, and hence didn’t share the link


#2

How do you get to that webpage?
Do you have a browser Object?
Do you have any other hyperlinks on that page?

if you know the result id or pattern you can do Find Element and pass below selector

<webctrl aaname='ABC*' tag='A' />

<webctrl aaname='ABC1234' tag='A' />

if you are sure there is no other hyperlink (there will be)

<webctrl aaname='*' tag='A' />

if element exists,

if element is found, you can do below (browser is your browser object)

image


#3

Thanks Vvaidya. The problem is, the result ID does not have a pattern as it varies every time based on the search. Say there are 10 records in DB with result ID (1,2,3…10) and based on the search, the result ID populates. Result ID can be 2 digit, 5 digits or 10 digits number, not in specific order, based on the number values in the DB.


#4

If you know the hyperlink address(or part of) you could do below

<webctrl aaname='*' href='*myinternaldomain*' tag='A' />