use of com.testsigma.automator.entity.ElementPropertiesEntity in project testsigma by testsigmahq.
the class ElementAction method constructElementWithDynamicXpath.
protected void constructElementWithDynamicXpath(String parameterizedXpath, String elementActionVarName, String testDataActionVarName, String attributeActionVariableName, boolean isAttributeToBeReplacedWith) throws AutomatorException {
ElementPropertiesEntity elementPropertiesEntity = new ElementPropertiesEntity();
String xpath = parameterizedXpath;
if (isAttributeToBeReplacedWith && attributeActionVariableName != null) {
log.info("Constructing XPATH with Pre-defined syntax: " + parameterizedXpath + " and attribute:" + getAttribute(attributeActionVariableName));
xpath = parameterizedXpath.replace(PARAMETERIZED_XPATH_PLACE_HOLDER, getAttribute(attributeActionVariableName));
} else if (testDataActionVarName != null) {
log.info("Constructing XPATH with Pre-defined syntax: " + parameterizedXpath + " and testdata:" + getTestData(testDataActionVarName));
xpath = parameterizedXpath.replace(PARAMETERIZED_XPATH_PLACE_HOLDER, getTestData(testDataActionVarName));
}
log.info("Constructed XPATH:" + xpath);
elementPropertiesEntity.setFindByType(FindByType.XPATH);
elementPropertiesEntity.setLocatorValue(xpath);
elementPropertiesEntity.setElementName("Dynamic element");
elementPropertiesEntity.setDynamicLocator(true);
Map<String, ElementPropertiesEntity> elementPropertiesMap = getElementPropertiesEntityMap();
if (elementPropertiesMap == null) {
elementPropertiesMap = new HashMap<>();
setElementPropertiesEntityMap(elementPropertiesMap);
}
getElementPropertiesEntityMap().put(elementActionVarName, elementPropertiesEntity);
}
use of com.testsigma.automator.entity.ElementPropertiesEntity in project testsigma by testsigmahq.
the class GetAllCheckboxesAction 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 CheckInvalidSelectorAction method execute.
@Override
protected void execute() throws Exception {
try {
getDriver().switchTo().alert();
this.suggestionActionResult = SuggestionActionResult.Failure;
throw new Exception();
} catch (NoAlertPresentException exception) {
}
JavascriptExecutor jsExecutor = driver;
Object frameSrc = jsExecutor.executeScript("return window.location.pathname");
getDriver().switchTo().parentFrame();
int size = getDriver().findElements(By.xpath("//iframe")).size();
if (!frameSrc.toString().equals("/") || size > 0) {
this.suggestionActionResult = SuggestionActionResult.Failure;
if (!frameSrc.toString().equals("/")) {
getDriver().switchTo().frame(getDriver().findElement(By.xpath("//iframe[@src='" + frameSrc + "']")));
}
throw new Exception();
}
ElementPropertiesEntity elementPropertiesEntity = getElementPropertiesEntity(NaturalTextActionConstants.TESTS_TEP_DATA_MAP_KEY_ELEMENT);
if (StringUtils.isBlank(elementPropertiesEntity.getLocatorValue())) {
this.suggestionActionResult = SuggestionActionResult.Success;
throw new Exception();
}
ElementSearchCriteria elementSearchCriteria = new ElementSearchCriteria(elementPropertiesEntity.getFindByType(), elementPropertiesEntity.getLocatorValue());
boolean isInvalid = false;
try {
getDriver().findElement(elementSearchCriteria.getBy());
this.suggestionActionResult = SuggestionActionResult.Failure;
isInvalid = true;
} catch (Exception e) {
this.suggestionActionResult = SuggestionActionResult.Success;
}
if (isInvalid) {
throw new Exception();
}
}
Aggregations