lokwk216
2 years agoNew Contributor
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 d...
- 2 years ago
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();