lkonduru
16 years agoOccasional Contributor
iterate and select values from drop-down menu
Hi,
In our application, we have a drop-down menu with around 10 items listed in it. I want to select each item in the drop-down and click on submit button. I want to iterate through each item in the drop down. The default selected item in the drop-down goes through fine. But my script is not able to select the second item from the drop-down and is returning me an error when trying to click on the 'Submit' button for the second item.
// to find the submit button on my webpage
submitButton = parentPage.Find("value","submit",100);
Log.Message("submitButton:" +submitButton.value) ;
// printing the properties of the drop-down menu (obtained from object browser)
Log.Message("Number of items: " + IntToStr(submission.wItemCount))
Log.Message("Items:\n" + submission.wItemList)
if (submission.length > 0) {
Log.Message(" Submission Type Count:" +submissionType.length) ;
// iterate through the drop-down
for (var i=0; i<=submission.wItemList; i++)
{
if (submission.idStr = type)
{
submission.set_SelectedIndex(i);
return true;
}
else {
Log.Message("No Submission Record found.");
}
Am I doing it the right way to iterate through the drop-down? else should i store the data in an array and then iterate over it. Please suggest.
Thanks in Advance,
Lakshmi
In our application, we have a drop-down menu with around 10 items listed in it. I want to select each item in the drop-down and click on submit button. I want to iterate through each item in the drop down. The default selected item in the drop-down goes through fine. But my script is not able to select the second item from the drop-down and is returning me an error when trying to click on the 'Submit' button for the second item.
// to find the submit button on my webpage
submitButton = parentPage.Find("value","submit",100);
Log.Message("submitButton:" +submitButton.value) ;
// printing the properties of the drop-down menu (obtained from object browser)
Log.Message("Number of items: " + IntToStr(submission.wItemCount))
Log.Message("Items:\n" + submission.wItemList)
if (submission.length > 0) {
Log.Message(" Submission Type Count:" +submissionType.length) ;
// iterate through the drop-down
for (var i=0; i<=submission.wItemList; i++)
{
if (submission.idStr = type)
{
submission.set_SelectedIndex(i);
return true;
}
else {
Log.Message("No Submission Record found.");
}
Am I doing it the right way to iterate through the drop-down? else should i store the data in an array and then iterate over it. Please suggest.
Thanks in Advance,
Lakshmi