use of com.testsigma.automator.entity.ElementPropertiesEntity in project testsigma by testsigmahq.
the class DragAndDropAction method getElement.
private WebElement getElement(String elementActionVarName, LocatorType locatorType, String locatorValue) throws Exception {
FindByType findByType = FindByType.getType(locatorType);
ElementPropertiesEntity elementPropertiesEntity = new ElementPropertiesEntity();
elementPropertiesEntity.setFindByType(findByType);
elementPropertiesEntity.setLocatorValue(locatorValue);
elementPropertiesEntity.setElementName("ui-iden");
elementPropertiesEntity.setDynamicLocator(true);
Map<String, ElementPropertiesEntity> elementPropertiesMap = getElementPropertiesEntityMap();
if (elementPropertiesMap == null) {
elementPropertiesMap = new HashMap<>();
setElementPropertiesEntityMap(elementPropertiesMap);
}
getElementPropertiesEntityMap().put(elementActionVarName, elementPropertiesEntity);
findElement(elementActionVarName);
return getElement();
}
use of com.testsigma.automator.entity.ElementPropertiesEntity in project testsigma by testsigmahq.
the class ElementAction method setElementSearchCriteria.
protected void setElementSearchCriteria(String elementActionVariableName) throws AutomatorException {
log.debug("Setting element search criteria");
ElementPropertiesEntity elementPropertiesEntity = getElementPropertiesEntity(elementActionVariableName);
if (StringUtils.isBlank(elementPropertiesEntity.getLocatorValue())) {
throw new AutomatorException(String.format(LOCATOR_VALUE_MISSING_ERROR_MSG, elementPropertiesEntity.getFindByType()));
}
elementSearchCriteria = new ElementSearchCriteria(elementPropertiesEntity.getFindByType(), elementPropertiesEntity.getLocatorValue());
}
use of com.testsigma.automator.entity.ElementPropertiesEntity in project testsigma by testsigmahq.
the class ListFrameAction method getElements.
private List<WebElement> getElements(String elementActionVarName, LocatorType locatorType, String locatorValue) throws Exception {
FindByType findByType = FindByType.getType(locatorType);
ElementPropertiesEntity elementPropertiesEntity = new ElementPropertiesEntity();
elementPropertiesEntity.setFindByType(findByType);
elementPropertiesEntity.setLocatorValue(locatorValue);
elementPropertiesEntity.setElementName("ui-iden");
elementPropertiesEntity.setDynamicLocator(true);
Map<String, ElementPropertiesEntity> elementPropertiesMap = getElementPropertiesEntityMap();
if (elementPropertiesMap == null) {
elementPropertiesMap = new HashMap<>();
setElementPropertiesEntityMap(elementPropertiesMap);
}
getElementPropertiesEntityMap().put(elementActionVarName, elementPropertiesEntity);
findElement(elementActionVarName);
return getElements();
}
use of com.testsigma.automator.entity.ElementPropertiesEntity in project testsigma by testsigmahq.
the class CheckElementIsInDifferentFrame method execute.
@Override
protected void execute() throws Exception {
ElementPropertiesEntity elementPropertiesEntity = getElementPropertiesEntity(NaturalTextActionConstants.TESTS_TEP_DATA_MAP_KEY_ELEMENT);
if (StringUtils.isBlank(elementPropertiesEntity.getLocatorValue())) {
throw new Exception();
}
ElementSearchCriteria elementSearchCriteria = new ElementSearchCriteria(elementPropertiesEntity.getFindByType(), elementPropertiesEntity.getLocatorValue());
WebElement elementInIframe = null;
JavascriptExecutor jsExecutor = driver;
String defaultPathName = (String) jsExecutor.executeScript("return window.location.pathname");
List<WebElement> iframes = getDriver().findElements(By.xpath("//iframe|//frame"));
Integer i = 1;
for (WebElement iframe : iframes) {
try {
getDriver().switchTo().defaultContent();
getDriver().switchTo().frame(iframe);
elementInIframe = getDriver().findElement(elementSearchCriteria.getBy());
Map<String, String> suggestions = new HashMap<String, String>();
// iframe.getAttribute("name")
suggestions.put("Frame Name", "");
suggestions.put("Frame Index", new Integer(i).toString());
engineResult.getMetaData().setSuggestions(new JSONObject().put("list", suggestions));
this.suggestionActionResult = SuggestionActionResult.Success;
break;
} catch (Exception e) {
continue;
}
}
if (defaultPathName != jsExecutor.executeScript("return window.location.pathname")) {
getDriver().switchTo().defaultContent();
List<WebElement> elements = getDriver().findElementsByXPath("//iframe[@src=\"" + defaultPathName + "\"]");
if (elements.size() > 0) {
getDriver().switchTo().frame(elements.get(0));
}
}
if (elementInIframe == null)
throw exception;
}
use of com.testsigma.automator.entity.ElementPropertiesEntity in project testsigma by testsigmahq.
the class DriverSessionCommand method createElementPropertiesMap.
private Map<String, ElementPropertiesEntity> createElementPropertiesMap(FindByType findByType, String locatorValue) {
ElementPropertiesEntity elementPropertiesEntity = new ElementPropertiesEntity();
Map<String, ElementPropertiesEntity> elementPropertiesEntityMap = new HashMap<>();
elementPropertiesEntity.setFindByType(findByType);
elementPropertiesEntity.setLocatorValue(locatorValue);
elementPropertiesEntityMap.put(NaturalTextActionConstants.TESTS_TEP_DATA_MAP_KEY_ELEMENT, elementPropertiesEntity);
return elementPropertiesEntityMap;
}
Aggregations