-
Notifications
You must be signed in to change notification settings - Fork 108
CheckList and DropList
Taisiia-Kozlova edited this page Nov 7, 2017
·
3 revisions
CheckLists and DropLists are complex elements, which allow users perform multi-selecting, checking and unchecking a number of options. For the sake of performance, JDI provides methods for operating with multiple elements, such as checkboxes and radio-buttons, which are nested in CheckLists and DropLists. Now there is no need to create check/uncheck methods for each element!
Example:
Here is the list of available methods.
Method | Description | Return Type |
---|---|---|
select(TEnum …) , select(String…) , select(int…) | Select options with name (use enum/text/index) from list (change their state selected/deselected) | |
check (TEnum …) , check (String…) , check (int…) | Check only specified options (use enum/text/index) from list (all other options unchecked) | |
uncheck(TEnum …) , uncheck (String…) , uncheck (int…) | Uncheck only specified options (use enum/text/index) from list (all other options checked) | |
checkAll() , selectAll() | Set all options checked | |
uncheckAll() , clear() | Set all options unchecked | |
getOptions() , getNames() , getValues() | Get labels of all options | List |
getOptionsAsText() | Get all options labels in one string separated with “; ” | String |
areSelected(); | Get names of checked options | List |
areDeselected(); | Get names of unchecked options | List |
waitSelected(TEnum …) , waitSelected(String…) | Wait while all options with names (use enum/text) selected. Returns false if this not happens | Boolean |
waitDeselected(TEnum …) , waitDeselected(String …) | Wait while all options with names (use enum/text) deselected. Returns false if this not happens | Boolean |
SetValue; HaveValue; | See methods by link |
Initialization of CheckList:
public ICheckList <T> checkList = new CheckList<T>();
@Override
protected void isSelectedAction (WebElement el) {
protected boolean isSelectedAction(WebElement el) {
return el.findElement(//By.xpath/css/…etc.).getAttribute("checked") != null;
}
};
Action > Examples:
@Test
public void selectMultipleStringsTest () {
ArrayList<String> expected = new ArrayList<String>();
options.add(//String value1);
options.add(//String value2);
checkList.getOprions(//String value1, String value2 );
Assert.assertEquals(checkList.areSelected, options);
}
@Test
public void getAllOptionsNames() {
//Assuming, there are only 2 options
ArrayList<String> expected = new ArrayList<String>();
options.add(//String value1);
options.add(//String value2);
ArrayList<String> actual = new ArrayList<String>();
actual = checkList.getOptions();
Assert.assertEquals(actual, expected);
}