web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Help with Web Scraping...
Power Automate
Answered

Help with Web Scraping a dropdown list

(0) ShareShare
ReportReport
Posted on by 42

Hi there,

I have the need to create a loop in where I need to click on all of the options in a dropdown list, which is dynamic based on the folder i have selected, so I need some help on how to do that.

So i have tried using the extract data from web page, and right-clicking the dropdown list and tried option, but it only ever records the 1st option for example "Add Document Type" is the selected option, and it only stores that in the variable.

 

I also found a post that used the extranct data from webpage element where you click advanced, select list in the dropdown and then in the CSS box put the following select[ddlDocType="searchDropDownDescription"] option, where ddlDocType is the ID of the select list, but that is not working.  I am sure i am missing something, but not sure what it is.

All of the other tutorials that i have found about web scraping are talking about tutorials for a list of books or items displayed on a web page, but cannot find anything for a select dropdown list, that has worked for me.

 

Can anyone out there help me?

Element in inspector

commalliance_0-1674719423322.png

 

dropdown list example

commalliance_1-1674719503106.png

 

 

I have the same question (0)
  • JonathanR Profile Picture
    22 on at

    Had a similar issue, ended up using a JS step to retrieve the values comma separated into a variable, then went from there using split text:

    function ExecuteScript() { 
    var a =document.getElementById("UserRole_RoleId_listbox").children.length
    var txt=""
    for(var i=0;i<a;i++)
    	{
    		txt=txt.concat(document.getElementById("UserRole_RoleId_listbox").children[i].innerText,",")
    	}
    return txt;
    }

    To give context and credit, this was the video that helped me:

    https://www.youtube.com/watch?v=p_248rQIrGc 

  • commalliance Profile Picture
    42 on at

    Thanks @JonathanR  I will have to take a look at the video and see if that works for my situation.

  • Highboy Profile Picture
    1,187 Super User 2024 Season 1 on at

    If you just need to click on all of them one by one without knowing how many entries there are in the list, you could just use "Set drop-down list value on webpage" and choose "Select options by index" and set "On error" to "Continiue flow run", and then go from 0-xxx on the index.
    When it reaches the end it wil fail silently and continue the script.

  • commalliance Profile Picture
    42 on at

    @Highboythat is something that I didn't think about that i will have to test.  My only question surrounding that would be that using your suggestion, if there was a selection that I didn't want the system to click on, but the index value varied, what would be the best way to accomplish that?

     

    For example: "Main" is an option that I do not want to select, but the index changes, so i need to have the flow avoid selecting that option all of the time.

    Any thoughts on the best and easiest way to accomplish that?

  • Highboy Profile Picture
    1,187 Super User 2024 Season 1 on at

    If yo never want to click on the first one, you can start your index at 1.

  • Verified answer
    commalliance Profile Picture
    42 on at

    So I looked, and the indexes were all over the place not in numerical order and there were gaps.  This is how I entered it in the action 0-50, but I kept getting errors stating it needed to be an integer.  When I looked at the code, each options index looked like this “25;;;”, so I ended doing what you suggested with the errors, but I had to modify it by just adding 25 actions, and using the names of each option.

    so it’s working, but just for my own curiosity, I’m sure there’s an easier way than making the number of actions equal to the number of options.  
    any ideas on that?

  • Verified answer
    momlo Profile Picture
    1,527 Super User 2024 Season 1 on at

    If you want to automate with pure PAD actions, you need 1 step that "clicks" each option if you specify the option via text, even if you use a loop.

     

    If you specify an option via index, and you know the pattern behind how these indexes are created by the page/app - you can create a loop and logic that will change the index variable, then use that variable as the index.

     

    Or use one PAD action to run the JS script and write a script that clicks all options via JS. This will be "one action" in a way you will hide all of the codings in the JS script.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 484

#2
11manish Profile Picture

11manish 282

#3
David_MA Profile Picture

David_MA 280 Super User 2026 Season 1

Last 30 days Overall leaderboard