UIPath return "href" in selector

Hi Guys

I am trying return the hyperlink URL from a button on a webpage. (due to organisational webpage, i could not publicly share the link)

I use the Get Attribute function, and simply using “href” in the attribute box does not return anything.

I realized that the attribute is a css-selector, with the link to be extracted as shown in the 2nd image below.

The href is currently activated/selected.

The selector editor currently shows this:

<html app='chrome.exe' title='TITLE*' /> <webctrl css-selector='body&gt;div&gt;div&gt;div&gt;div&gt;div&gt;article&gt;div&gt;div&gt;p&gt;a' href='https://LINK TO BE EXTRACTED.com' parentid='the-post' tag='A' /> <webctrl css-selector='body&gt;div&gt;div&gt;div&gt;div&gt;div&gt;article&gt;div&gt;div&gt;p&gt;a&gt;img' parentid='the-post' tag='IMG' />

May I please seek your help on what I should do to return the href address link? Or if there is another way to do this?

Thank you in advance.

Hi @Ben_l

In your get attribute you have to give a tag contains ‘a’ to get the href property put.

So from the current selector remove the img line and find reliable attributes to identify only till the ‘a’ tag

Cheers

Hi,

In this case, I recommend to use Visual Tree of UiExplorer


First, indicate the target element.
Next, if the element doesn’t contain A tag, click element which is A around the current target in Visual Tree and set it as target element using right click.
Finally use GetAttribute activity with the above selector.

Regards,

1 Like

Thanks for the reply, I have set the A tag (Just above the IMG) to Target element, as below. Are there any other boxes I need to check to expose the href ?

The link is stored in the 2nd last tag, and I have ‘added’ it, and also ticked the href box on the right side panel.

Hi,

The above image seems not set A as target. Can you try to set it as target like A tag is at bottom of the selector as the following image.

Then if the href is dynamic, can you try to uncheck href attribute from the selector, then try to use GetAttribute with it?

Regards,

Thanks! that works now! appreciate it @Yoichi :grinning:

1 Like

@Yoichi

I have a follow-up question on this. I am trying to run this through a loop, which opens a list of webpage (each containing a button with URL to be extracted) from a datatable.

However, when I return the href, it keeps returning the button URL from the first webpage. Somehow, while the correct webpage opens in Chrome, the Get Attribute tool only extracts from the 1st webpage.

Hi,

I think it’s selector and/or attach browser matter.
Perhaps you should raise a new topic with specific image etc because it’s apart from title of this topic, and it will help those who face same matter.

Regards.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.