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!
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.
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”
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
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.
On the topic of querying a database from the command line, here’s an example that uses mySql:
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:
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