Skip to content

Dropdown, Selector, RadioButtons, Tabs and Menu

Taisiia-Kozlova edited this page Nov 7, 2017 · 2 revisions

All above stated entities are various implementations of the common idea of a complex element. In general, complex element may contain a number of nested simple elements, such as checkboxes, links, buttons, etc. JDI provides different names for each implementation, so you could programmatically describe actual web page’s content. Below provided are various examples of complex elements’ possible views.

Example:

Dropdown/Selector/RadioButtons/Tabs/Menu/ComboBox

Here is the list of available methods.

Method Description Return Type
select(TEnum) , select(String) , select(int) Select element with name (use enum/text/index) from list void
getOptions() , getNames() , getValues() Get labels of all options List
getOptionsAsText() Get all options labels in one string separated with “; ” String
getSelected() Get name of the selected element String
getSelectedIndex() Get index of the selected element Int
**isSelected(TEnum) , isSelected(String) ** Is option (from enum/text/int) selected? boolean
waitSelected(TEnum) , waitSelected(String) Wait while option (from enum/text/int) selected. Returns false if this not happens boolean
SetValue; HaveValue; See methods by link

Initialization of DropDown:

public IDropDown<T> dropDown = new DropDown<T>(By.xpath("//dropdown xpath”);
	@Override
	protected void selectAction(String name) {
         	expand();
		getDriver().findElement(By.xpath(("//common options xpath” + name);
		close;

Initialization of other Elements:

@FindBy(xpath = "//element’s xpath + ‘%s’(here goes option’s name/index")
public //element type <T> element;

Action > Examples:

@Test
public void selectStringTest() {
    element.select(//String value);
    Assert.assertTrue(element.isSelected(//String value));
}

@Test
public void selectStringTest() {
    String expected = //String value;
    String actual = element.getName();
    Assert.assertEquals(actual, expected);
}

See more examples on GitHub

Clone this wiki locally