use of com.seleniumtests.uipage.htmlelements.HtmlElement in project seleniumRobot by bhecquet.
the class SeleniumNativeActions method interceptPageFactoryElementsLocation.
/**
* Intercept "findElements" action done in LocatingElementListHandler class so that we can override returned element and replace it by HtmlElement
* This helps handling PageObjectFactory method
* @param joinPoint
* @return
* @throws Throwable
*/
@Around(" this(org.openqa.selenium.support.pagefactory.internal.LocatingElementListHandler) && call(public * org.openqa.selenium.support.pagefactory.ElementLocator+.findElements (..))")
public Object interceptPageFactoryElementsLocation(ProceedingJoinPoint joinPoint) throws Throwable {
if (doOverride()) {
DefaultElementLocator locator = ((DefaultElementLocator) joinPoint.getTarget());
Field byField = DefaultElementLocator.class.getDeclaredField("by");
byField.setAccessible(true);
return new HtmlElement("", (By) byField.get(locator), getCurrentFrame()).findElements();
} else {
return joinPoint.proceed(joinPoint.getArgs());
}
}
use of com.seleniumtests.uipage.htmlelements.HtmlElement in project seleniumRobot by bhecquet.
the class AngularMaterialSelect method getOptions.
@Override
public List<WebElement> getOptions() {
parentElement.findElement(locatorClickToOpen).click();
if (locatorParentOfDropdown == null) {
String classes = new HtmlElement("", new ByAll(By.className(CLASS_MAT_SELECT_PANEL), By.className(CLASS_MAT_SELECT_CONTENT)), frameElement).getAttribute("class");
if (classes.contains(CLASS_MAT_SELECT_CONTENT)) {
locatorParentOfDropdown = By.className(CLASS_MAT_SELECT_CONTENT);
} else {
locatorParentOfDropdown = By.className(CLASS_MAT_SELECT_PANEL);
}
}
options = new HtmlElement("options", locatorParentOfDropdown, frameElement).findHtmlElements(locatorOption).stream().map(CachedHtmlElement::new).collect(Collectors.toList());
return options;
}
use of com.seleniumtests.uipage.htmlelements.HtmlElement in project seleniumRobot by bhecquet.
the class AngularSelect method finalizeAction.
/**
* Finalize any action. As for these combobox, we must click on it to get option list, it's a way to close it
* if 'locatorClickToclose' is not null, we click on it if 'locatorParentOfDropdown' is present
* else, we send "ESC" on parent
*/
@Override
public void finalizeAction() {
handleAlert();
HtmlElement selectContent = new HtmlElement("options", locatorParentOfDropdown, frameElement);
if (selectContent.isElementPresent(0)) {
if (locatorClickToclose != null) {
parentElement.findElement(locatorClickToclose).click();
} else {
parentElement.sendKeys(Keys.ESCAPE);
}
}
}
use of com.seleniumtests.uipage.htmlelements.HtmlElement in project seleniumRobot by bhecquet.
the class AngularSelect method getOptions.
/**
* Method for getting list of options when this list is not available without clicking the list
* It first click on element located by 'locatorClickToOpen' element
* This should make the element located by 'locatorParentOfDropdown' available in DOM
* => we look for all options located by 'locatorOption'
* All these options are cached so that combobox can be closed. It will not be necessary to open it to know the value of an element.
*/
@Override
public List<WebElement> getOptions() {
parentElement.findElement(locatorClickToOpen).click();
HtmlElement dropdownElement = new HtmlElement("options", locatorParentOfDropdown, frameElement);
if (debug) {
logger.info("drop down HTML");
logger.info(dropdownElement.getAttribute("outerHTML"));
}
options = dropdownElement.findHtmlElements(locatorOption).stream().map(CachedHtmlElement::new).collect(Collectors.toList());
return options;
}
use of com.seleniumtests.uipage.htmlelements.HtmlElement in project seleniumRobot by bhecquet.
the class TestDriver method testFindElements.
public void testFindElements() {
// 2 elements to find
Assert.assertEquals(new HtmlElement("", By.name("divFindName")).findElements().size(), 2);
// 4 elements to find, one in a branch
Assert.assertEquals(new HtmlElement("", By.className("myClass")).findElements().size(), 4);
}
Aggregations