use of com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxWebElement in project wcomponents by BorderTech.
the class SeleniumWComponentsUtil method wrapInputElementWithTypedWebElement.
/**
* Analyze the input element and attempt to wrap it in the appropriate component-specific subclass. If not component
* specific subclass can be identified then the element will be wrapped in a SeleniumWComponentWebElement.
*
* @param driver the WebDriver.
* @param element the default Selenium WebElement.
* @return a subtype of SeleniumWComponentWebElement specific to the element type.
*/
public static SeleniumWComponentInputWebElement wrapInputElementWithTypedWebElement(final WebDriver driver, final WebElement element) {
String tag = element.getTagName();
if (tag.equals(SeleniumWComponentInputWebElement.EDITABLE_TAG)) {
String type = element.getAttribute("type");
WebElement el = element.findElement(By.xpath(".."));
switch(type) {
case SeleniumWCheckBoxWebElement.TYPE:
return new SeleniumWCheckBoxWebElement(el, driver);
case SeleniumWTextFieldWebElement.TYPE:
// Text fields have a wrapping Span, we want to wrap that
return new SeleniumWTextFieldWebElement(el, driver);
case SeleniumWEmailFieldWebElement.TYPE:
return new SeleniumWEmailFieldWebElement(el, driver);
case SeleniumWRadioButtonWebElement.TYPE:
return new SeleniumWRadioButtonWebElement(el, driver);
default:
return new SeleniumWComponentInputWebElement(el, driver);
}
} else if (tag.equals(SeleniumWTextAreaWebElement.TEXTAREA_TAG)) {
return new SeleniumWTextAreaWebElement(element.findElement(By.xpath("..")), driver);
} else if (tag.equals(SeleniumWSelectWebElement.SELECT_TAG)) {
return new SeleniumWSelectWebElement(element.findElement(By.xpath("..")), driver);
}
return new SeleniumWComponentInputWebElement(element, driver);
}
use of com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxWebElement in project wcomponents by BorderTech.
the class WDropdownOptionsExample_Test method configureDropDown.
/**
* Updates the controls to produce the expected dropdown.
*
* @param driver the selenium driver
* @param type the type of drop down.
* @param actionNumber the number of the action to use, base off position in the radio button select.
*/
private void configureDropDown(final SeleniumWComponentsWebDriver driver, final WDropdown.DropdownType type, final int actionNumber) {
// action on change.
SeleniumWCheckBoxWebElement actionOnChange = driver.findWCheckBox(byWComponentPath("WCheckBox[1]"));
while (!actionOnChange.isSelected()) {
actionOnChange.click();
}
WebElement action = driver.findWCheckBox(byWComponentPath("WCheckBox[" + actionNumber + "]"));
while (!action.isSelected()) {
action.click();
}
driver.findElement(byWComponentPath("WRadioButtonSelect[0]", type)).click();
// set null option to true.
SeleniumWCheckBoxWebElement includeNullOption = driver.findWCheckBox(byWComponentPath("WCheckBox[0]"));
while (!includeNullOption.isSelected()) {
includeNullOption.click();
}
driver.findElement(byWComponentPath("WDropdownOptionsExample/WFieldSet/WButton")).click();
}
Aggregations