Get the URL for multiple profiles by passing counter

Dear Team,

I want pass the counter variable to the javascript by using while loop to get the URL for every Profile which is available in web page.

I am using below JS on some other platform, want to know how to do the same in UiPath.

Code:>

var link = document.getElementsByClassName(“candidate-headline flex-row flex-aic”)[#$Counter#$].getElementsByTagName(“a”)[0].href;
return link;

If you need anything more info, please let me know.

Thanks & Regards,
Amol Golhar

Hello @Amol_Golhar Welcome to the UiPath Community Forum

In UiPath, mostly extraction is done by scraping the data. If you are new to UiPath, I will advise you to go through the UiPath Academy - Associate Training.

UiPath Academy

Also, can you elaborate on your requirement, so that I can provide you assistance in better way.
In UiPath, we use Selector to identify the element and extract data same as JS function.
Attaching a video for you reference: Extracting URLs From A Webpage Without Data Scrapping | UiPath | Data Extraction

Thanks

depending on some element structure details there are some several activities / options:

  • Data Scrapping / Table Extraction / its Derivate: for each Ui Element
  • Find children
  • Loops and essential element/value retrieval activities

A concept of injecting variables within a selector is e.g. Dynamic Selectors:

Dear Team,

Thank you fro the response.
My requirement:

I have a multiple profiles on one webpage, like below
Profile1
Profile2
Profile3
Profile4
Profile5

i have to open every profile and get the some details, but when i click on profile1 it will opening a new page, i want extract the URL for profile1 and open in the same page, then go back and extract the URL for Profile2, same i want do for all profiles by using while loop, total profile count is available on webpage itself.

The logic is i want pass the counter vaule to the code by using same while loop, so it will extract the URL for each profile and i will pass that URL to Go to URL activity.

I have modified code, please check and let me know correction.

“function(counter){
var link = document.getElementsByClassName(‘candidate-headline flex-row flex-aic’)[counter].getElementsByTagName(‘a’)[0].href;
return link;
}”

Thanks & Regards,
Amol Golhar

Dear Shantanu,

I have replied the requirement in more detail, please check the Post.

Thanks & Regards,
Amol Golhar

maybe you can share a screenshot of it along with some details on the element stuctures (UIExpliorer, Browser F12 WebTools)

we agree with this statement and recommend to self-train the essentials when starting new UiPath.

Hello @Amol_Golhar Thank you for the detailed instruction’s. Looking at the scenario, I am confused that why are using JS Function to get the link. There are other methods using which you can extract the links and process further.

One of the example is Get Attribute Activity - Get Attribute

I am attaching a sample workflow where I have used W3Schools website which I think mimics the same behaviour that you are facing with your website. I am extracting links from the side-panel Headers and navigating into them one by one.
As mentioned in below screenshot, I have used two approaches :

  • Data Scraping - It returns datatable of Headings and URL
  • Dynamic Selector - It has dynamic selector which uses counter mechanism and while loop to navigate

LinkScraping
Test-2.xaml (28.8 KB)

Please let me know if it fits your use-case.

Thanks

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