interaction with multiple drop-down lists
Hello,
I am running Testcomplete 15.40.421. In my testing scenario, there are two drop-down lists on the same page. The items in the first list is dynamic, and the second drop-down list changes dynamically as well based on the selected value of the first drop-down list.
I want to record down the values in the second drop-down when selecting different items in the first drop-down, but am stuck at creating a loop for the first dynamic list. Is there a simple way to achieve this?
Your help would be greatly appreciated!! Thank you.
I often need to capture dynamic values and I store them in an array, then access each array value for other reasons. Here I pass in the drop down object to the function to capture the options within an array...
function CaptureSelectBoxOptions(SelectBoxOptionsList) { const values = []; let TotalOptions = SelectBoxOptionsList.ChildCount; //Log.Message(TotalOptions, "", 0); for (let i = 0; i < TotalOptions; i++) { if (SelectBoxOptionsList.Child(i).contentText != "") { values.unshift(SelectBoxOptionsList.Child(i).contentText); } } return values; //Returns an array of the values from the select box. }
You could then iterate through that array to click on each value so the second drop down populates, and capture the values in the same manner. Or you could probably just add something like this to the if statement above to capture and click them at the same time:SelectBoxOptionsList.Child(i).Click();
You may also need to refresh the TestComplete object tree cache to capture the newly populated values (from the second drop down) after clicking an option in the first drop down using something like this:Aliases.browser.PageName.DropDown2Name.Refresh();