lkonduru
15 years agoOccasional Contributor
ListBox select item fails
I am using J script to select a item from list box in a loop and click submit button. When i use either 'SelectedItem(i)' or 'ClickItem(i)',
it throws run time error. I really appreciate your help.
Here is the script snippet
function filterSubmission() {
var url, process, page, submitButton, submissionType, submissionTypeString, submissionTypeSeparator, submissionTypeItem;
url = "http://host:8080/app/abc.do";
process = Sys.Process("firefox");
page = process.Page("*");
page.ToUrl(url);
submitButton = page.Find("value", "SubmitX", 100);
submissionType = page.Find("idStr", "type", 100);
Log.Message("Number of items: " + IntToStr(submissionType.wItemCount)) ;
if (submissionType.wItemCount > 0) {
submissionTypeString = submissionType.wItemList; // this string has values = "all;option0;option1;option2"
submissionTypeSeparator = submissionType.wListSeparator;
aqString.ListSeparator = submissionTypeSeparator;
for (var i=0; i<submissionType.wItemCount; i++) {
submissionTypeItem = aqString.GetListItem(submissionTypeString, i);
submissionTypeItem.ClickItem(i); // throws runtime error
if (!submitButton.Exists) {
submitButton = page.Find("value", "Filter Results", 100);
}
submitButton.Click();
page.Wait();
}
}
}
it throws run time error. I really appreciate your help.
Here is the script snippet
function filterSubmission() {
var url, process, page, submitButton, submissionType, submissionTypeString, submissionTypeSeparator, submissionTypeItem;
url = "http://host:8080/app/abc.do";
process = Sys.Process("firefox");
page = process.Page("*");
page.ToUrl(url);
submitButton = page.Find("value", "SubmitX", 100);
submissionType = page.Find("idStr", "type", 100);
Log.Message("Number of items: " + IntToStr(submissionType.wItemCount)) ;
if (submissionType.wItemCount > 0) {
submissionTypeString = submissionType.wItemList; // this string has values = "all;option0;option1;option2"
submissionTypeSeparator = submissionType.wListSeparator;
aqString.ListSeparator = submissionTypeSeparator;
for (var i=0; i<submissionType.wItemCount; i++) {
submissionTypeItem = aqString.GetListItem(submissionTypeString, i);
submissionTypeItem.ClickItem(i); // throws runtime error
if (!submitButton.Exists) {
submitButton = page.Find("value", "Filter Results", 100);
}
submitButton.Click();
page.Wait();
}
}
}