# Can I read and process all values in a pulldown list?

**URL:** <https://forums.eggplantsoftware.com/t/can-i-read-and-process-all-values-in-a-pulldown-list/2561>\
**Category:** Eggplant Functional\
**Created:** [February 22, 2010, 12:48am UTC](https://forums.eggplantsoftware.com/t/can-i-read-and-process-all-values-in-a-pulldown-list/2561 "2010-02-22T00:48:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![swebsurf](https://forums.eggplantsoftware.com/letter_avatar_proxy/v4/letter/s/e99b99/32.png) [@swebsurf](https://forums.eggplantsoftware.com/u/swebsurf)\
**Post date:** [February 22, 2010, 12:48am UTC](https://forums.eggplantsoftware.com/t/can-i-read-and-process-all-values-in-a-pulldown-list/2561/1 "2010-02-22T00:48:40Z")

</div>

Hi,

I am testing a web app that contains a pulldown list of dynamic unpatterned values, eg, ‘201’,‘30.2’,‘ALT’; the length of the list at runtime is unknown. I would like to be able to read the values in that pulldown list into a container and loop through the values in the container, entering them in a text field on the screen.

I guess the basic questions are:  
1 - how can i read the values from a pulldown list?  
2 - how can i tell how long the list is?

thanks,  
swebsurf

ps: Great forum!

---

<div class="post-metadata">

**Author:** ![EggplantMatt](https://forums.eggplantsoftware.com/user_avatar/forums.eggplantsoftware.com/eggplantmatt/32/3_2.png) [@EggplantMatt](https://forums.eggplantsoftware.com/u/EggplantMatt)\
**Post date:** [February 22, 2010, 9:23am UTC](https://forums.eggplantsoftware.com/t/can-i-read-and-process-all-values-in-a-pulldown-list/2561/2 "2010-02-22T09:23:36Z")

</div>

Actually reading text from the screen is not a strength of eggPlant – it’s sometimes possible to do, but it requires a bit of work to set up. If you can’t select the text and copy it to the clipboard (usually not possible with a drop down list), then it’s preferable to access the same source material that is generating the list. If the data comes from a text file, it’s easy to iterate over the values in the file and pass those data to a TypeText command or use those data to generate Text Images. Or if the data is in a database, and the database can be queried via the command line, then you can use the Shell command to make a call to the database to get the values.

---

<div class="post-metadata">

**Author:** ![coolmahen](https://forums.eggplantsoftware.com/letter_avatar_proxy/v4/letter/c/f9ae1b/32.png) [@coolmahen](https://forums.eggplantsoftware.com/u/coolmahen)\
**Post date:** [February 22, 2010, 11:43am UTC](https://forums.eggplantsoftware.com/t/can-i-read-and-process-all-values-in-a-pulldown-list/2561/3 "2010-02-22T11:43:38Z")

</div>

Matt,  
It will be helpful if you explain little more on database connectivity for fetching data as you mentioned  
“If the data is in a database, and the database can be queried via the command line, then you can use the Shell command to make a call to the database to get the values”

---

<div class="post-metadata">

**Author:** ![coolmahen](https://forums.eggplantsoftware.com/letter_avatar_proxy/v4/letter/c/f9ae1b/32.png) [@coolmahen](https://forums.eggplantsoftware.com/u/coolmahen)\
**Post date:** [February 22, 2010, 12:02pm UTC](https://forums.eggplantsoftware.com/t/can-i-read-and-process-all-values-in-a-pulldown-list/2561/4 "2010-02-22T12:02:12Z")

</div>

```auto
params b
SetOption ImageSearchCount,1
If ImageFound (b)
then
	Click b
else
	If ImageFound ("vscroll") -- vertical Scroll bar
	then
		DragAndDrop "vscroll","uparrow_max" -- drag the scroll bar to top most point 
		If ImageFound(b) 
		then
			Click b
		else
			repeat until ImageFound("vdown_arrow_max") -- the last max point where scroll bar can move
				Click "downarrow" -- down arrow which is used after every search 
				put Mouselocation() into aloc
				setSearchRectangle((aloc+(-190,-130)),(aloc+(15,10))) -- it's one end is hard coded based on the length & width required 
				If ImageFound (b)
				then	
					Click b
					put true into result
					exit repeat
				else
					put false into result
				end if 
			end repeat
			
			If result is false 
			then
				LogError "Not Found in the Drop down "&b
			else
				Log "Found in the Drop down "&b
			end if 	
		end if
	else 
		LogError " Not Found in the Dropdown: "&b
	end if
end if
set the SearchRectangle to ()

```

This code work fine for me.Whenever i need of verify a dropdown list .i will call this script

```auto
Run "h_dropdown" "value of b"

```

only thing is that,you need of know images in the dropdownlist before.

Can anyone suggest a better way do it.

---

<div class="post-metadata">

**Author:** ![EggplantMatt](https://forums.eggplantsoftware.com/user_avatar/forums.eggplantsoftware.com/eggplantmatt/32/3_2.png) [@EggplantMatt](https://forums.eggplantsoftware.com/u/EggplantMatt)\
**Post date:** [February 26, 2010, 2:09pm UTC](https://forums.eggplantsoftware.com/t/can-i-read-and-process-all-values-in-a-pulldown-list/2561/5 "2010-02-26T14:09:14Z")

</div>

On the topic of querying a database from the command line, here’s an example that uses mySql:

```auto
set theShell to "/bin/bash"
open process theShell
set mysql to "/usr/local/mysql/bin/mysql"
set SQL to "select * from pet;"
write mysql & return to process theShell
// interactive session with DB
write "use test;" & return to process theShell
write SQL & return to process theShell
write "exit" & return to process theShell
read from process theShell until end
put it
close process theShell

```

Once you’ve opened the shell process, you can have it execute calls to mySQL as needed:

```auto
set theShell to "/bin/bash"
open process theShell
set mysql to "/usr/local/mysql/bin/mysql"
put ("cat", "dog", "bird", "fish","ferret") into speciesList
repeat with each species of speciesList
	write mysql & return to process theShell
	write "use test;" & return to process theShell
	set SQL to "select * from pet where species is" && species & ";"
	write SQL & return to process theShell
	write "exit" & return to process theShell
	read from process theShell until end
	put it
end repeat
close process theShell

```
