Forum Discussion

lkonduru's avatar
lkonduru
Occasional Contributor
15 years ago

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();      

    }      

  }    

}
  • Hello Lakshmi,


    First, please let us make it clear at what point of our discussion we are. In our Support Live Chat, you were suggested to use the submissionType.ClickItem(i) method:





      for(var i = 0; i<submissionType.wItemCount; i++){


        submissionType.ClickItem(i);


      }






    After you have followed the recommendation, you have got the 'jscript runtime error' with the 'unspecified error' remark. To help us investigate this problem, please pack the entire project suite along with the test logs and send it to Support.




    Additionally, please collect the Event View information as described in the steps below and send it to Support.




    1. Download a free trial version of AQtime 7, which is our profiling tool, from our web site. You can request it on the following page of our web site:


    http://www.automatedqa.com/downloads/aqtime/




    2. Install the tool.




    3. Start AQtime with the -NotOpenApp command-line argument. For example, you can use the following command line:


    "c:\Program Files\Automated QA\AQtime 7\Bin\AQtime.exe" -NotOpenApp




    4. Select the 'File | New Project From Module...' main menu item.




    5. In the Open File dialog, select the TestComplete.exe file and click Open.




    6. Take a look at the AQtime toolbar - there is a combo box. Open it and select the "Tracing | Exception Trace Profiler" item.




    7. Select the "Options | Options..." main menu command - the Options dialog will appear. 



    8. Set the "Profiling Time | Event View | General | Exceptions | Depth shown" setting to 100 and click OK.




    9. Click the Run toolbar button (the green arrow) or press F5 to start profiling.




    10. AQtime will start TestComplete and trace all the exceptions that will occur in the application until it is closed.




    11. Reproduce the problem in TestComplete.




    12. After the problem occurs, right-click somewhere within the Event View panel (it is opened by default at the bottom of AQtime's window) and select the 'Save All...' item.




    13. Save the panel's contents to an HTML file and send me the file via our Contact Support form.




    Thanks in advance.
  • lkonduru's avatar
    lkonduru
    Occasional Contributor
    Alex,



    Thanks. I posted the zip containing suite and log. I ran the same script in "iexplore" instead of  "firefox", this time i am not getting jscript runtime error. Here is what script does



    - select item from combo box

    - click submit button

    - continue to next item in combo box



    The loop does not continue after click submit button but if i comment it out i can see the loop continues with next item in the combo box.



     if (submissionType != null && submissionType.wItemCount > 0) {

        submissionTypeString = submissionType.wItemList;

        submissionTypeSeparator = submissionType.wListSeparator;

        aqString.ListSeparator = submissionTypeSeparator;

        

        for (var i = 0; i<submissionType.wItemCount; i++) {

           submissionType.ClickItem(i);

                     

           if (!submitButton.Exists) {

              submitButton = page.Find("value", "Filter Results", 100);

           }

           //all the items in the combo box are selected when this line is comment..

           //if not ends with first selection and successful submit.

           submitButton.Click();     

           page.Wait();

        }

    }       

      

    Thanks

  • Hello Lakshmi,





    We have received your test project, thank you. We will let you know our results via email.