Jump to content



Photo

Loop Through Items In A Web Dropdown List

loop dropdown

  • Please log in to reply
3 replies to this topic

#1 dyvel

dyvel

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 133 posts
  • LocationDenmark
  • OS:Windows 8
  • Total Memory:8Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 15 December 2014 - 11:38 AM

Hi

 

I'm trying to create a bot that will loop through a dropdown list and perform actions on each selection. 

My problem is the iteration of the dropdown.

 

Can any of you advise on how to do a simple loop through a dropdown list from a website?

 

Thanks in advance!



#2 Bot-Factory (Dan)

Bot-Factory (Dan)

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 3108 posts
  • LocationEurope/Germany
  • OS:Windows 8
  • Total Memory:8Gb
  • Framework:v4.0
  • License:Developer Edition

Posted 15 December 2014 - 04:05 PM

Depends a bit on the website. But in general it should be possible to scrape the drop down menu entries from the html code. 
So you basically would do:

 

add list to list  (with scrape attribute extracting the dropdown elements)
then loop through the list and perform the action. 

Use change dropdown to select the correct dropdown menu setting. 

But it all starts with putting the dropdown menu options into a list. 
 

Dan


Signature-JPG.jpg


#3 HelloInsomnia

HelloInsomnia

    Advanced Member

  • Moderators
  • 3067 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 15 December 2014 - 05:48 PM

Here is a visual representation of what Dan said
 

Edit: misread it at first, now it is corrected.

navigate("http://ubotsandbox.com/drop-down-boxes.php", "Wait")
wait(3)
clear list(%cities)
comment("We get the child elements of the dropdown named \"cities\"
the child elements are the <option> and the value is what
we are targeting")
add list to list(%cities, $scrape attribute(<tagname="option">, "value"), "Delete", "Global")
loop($list total(%cities)) {
    alert("Changing city")
    change attribute(<name="cities">, "value", $next list item(%cities))
    wait(1)
    comment("Do whatever you want here")
}



#4 dyvel

dyvel

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 133 posts
  • LocationDenmark
  • OS:Windows 8
  • Total Memory:8Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 16 December 2014 - 12:46 PM

Got it!

 

Thank you both!

Appreciate the helping hand :-)







Also tagged with one or more of these keywords: loop, dropdown

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users