use of com.testsigma.automator.actions.ElementSearchCriteria in project testsigma by testsigmahq.
the class DriverSessionActionsController method findElements.
@GetMapping(value = "/find_elements")
@ResponseStatus(HttpStatus.OK)
public List<MobileElementDTO> findElements(@PathVariable("session_id") String sessionId, @RequestParam("platform") Platform platform, @RequestParam("locatorType") LocatorType locatorType, @RequestParam("byValue") String byValue) throws MobileAutomationServerCommandExecutionException {
FindByType findByType = FindByType.getType(locatorType);
ElementSearchCriteria elementSearchCriteria = new ElementSearchCriteria(findByType, byValue);
log.info("Request for searching Elements in session - " + sessionId);
List<MobileElement> mobileElements = driverSessionCommand.findElements(sessionId, platform, elementSearchCriteria);
return mobileElementMapper.map(mobileElements);
}
use of com.testsigma.automator.actions.ElementSearchCriteria 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