s5h
12 years agoContributor
Selecting an item from combobox/dropdownlist
Hi
I was wondering is it possible to select an item based on caption/index from a combobox/dropdown in a keyword test?
My combobox did not have the ClickItem method mentioned in other posts so I added it in the Object mapping settings Win32Controls/Combobox and I now can use the Click Item method.
The problem I am having is this:
I click on the combobox and it opens the dropdown. I then want to click on an item based on the caption, so have combox.clickitem("City") but it will not click on anything and the error posted to the log is "Drop down box cannot be opened".
I also tried a For..loop which iterates through the list and if the displaytext = myparamter then click on it. This isn't working for me.
The dropdown list maps to a different location to the combobox. So should I be using clickitem on the combobox or the dropdown list.
Hope you can help
I was wondering is it possible to select an item based on caption/index from a combobox/dropdown in a keyword test?
My combobox did not have the ClickItem method mentioned in other posts so I added it in the Object mapping settings Win32Controls/Combobox and I now can use the Click Item method.
The problem I am having is this:
I click on the combobox and it opens the dropdown. I then want to click on an item based on the caption, so have combox.clickitem("City") but it will not click on anything and the error posted to the log is "Drop down box cannot be opened".
I also tried a For..loop which iterates through the list and if the displaytext = myparamter then click on it. This isn't working for me.
The dropdown list maps to a different location to the combobox. So should I be using clickitem on the combobox or the dropdown list.
Hope you can help
- Hi Siobhan!
Please check again your mapping item, you can find item's menthods by Method tab in Advanced view to make sure that the methods are avaiable.
Hope this code can help you:
/**Looking for a filter name in Filter Name dropdownlist*/
function Verify_Filter_Name_Exist_In_List(filter_name)
{
try
{
var Obj=Aliases["pageInventoryDetailReport"]["list_Filter_Name"];//list_FIlter_Name appears after user clicked on combobox
var i;
if(!Obj["VisibleOnScreen"])
{
Aliases["pageInventoryDetailReport"]["cb_Filter_Name"]["Click"]();// cb_Filter_Name is a combo box
}
for(i=0;i<Obj["wItemCount"];i++)
{
if(Obj["wItem"](i)==filter_name)
{
return true;
}
}
return false;
}catch(ex)
{
Messageshow=ex["description"];
return false;
}
}