Topic
No replies
SystemAdmin
SystemAdmin
16727 Posts
ACCEPTED ANSWER

Pinned topic Reg:Read Combo Box List Values and Select and Read Selected Value in Java

‏2012-11-06T12:17:54Z |
Hi All,
The below Code may help in working on list Combo box elements the below code counts number of options/list values present in combo box ans checks the value which you want to select and reads back the selected values is displaying correctly or not.

public static boolean fnSelectList(String strVal, TestObject testObj) throws Exception
{
boolean temp = false;
ITestDataList CountList = (ITestDataList)testObj.getTestData("list");
SelectGuiSubitemTestObject listObj = (SelectGuiSubitemTestObject) testObj;

for(int i=0;i<=CountList.getElementCount()-1;i++){
String objlist = (String) CountList.getElements().getElement(i).getElement().toString();

if(objlist.equals(strVal)){
listObj.select(strVal);
temp = true;

// To Make Sure The Selected Value is Displaying in the list.
if(temp){
if((listObj.getSelectedText()).equals(strVal)){
System.out.println("PASS");
}else{System.out.println("FAIL");}
}
break;
}

if(i==CountList.getElementCount()-1){
System.out.println("The List Option is Not Present in The List");
}
}
return temp;
}

any improvement to the above hearty welcome
Regards,
Sandeep S S